Skip to content

Commit 6c93c16

Browse files
committed
Resolved the codegen tests for or intrinsic
1 parent 584548f commit 6c93c16

File tree

2 files changed

+18
-34
lines changed

2 files changed

+18
-34
lines changed

clang/lib/Sema/SemaHLSL.cpp

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2291,36 +2291,19 @@ bool SemaHLSL::CheckBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) {
22912291

22922292
break;
22932293
}
2294-
case Builtin::BI__builtin_hlsl_and: {
2295-
if (SemaRef.checkArgCount(TheCall, 2))
2296-
return true;
2297-
if (CheckVectorElementCallArgs(&SemaRef, TheCall))
2298-
return true;
2299-
if (CheckScalarOrVector(&SemaRef, TheCall, getASTContext().BoolTy, 0))
2300-
return true;
2301-
2302-
ExprResult A = TheCall->getArg(0);
2303-
QualType ArgTyA = A.get()->getType();
2304-
// return type is the same as the input type
2305-
TheCall->setType(ArgTyA);
2306-
break;
2307-
}
2294+
case Builtin::BI__builtin_hlsl_and:
23082295
case Builtin::BI__builtin_hlsl_or: {
23092296
if (SemaRef.checkArgCount(TheCall, 2))
23102297
return true;
23112298
if (CheckVectorElementCallArgs(&SemaRef, TheCall))
23122299
return true;
2313-
2314-
// Ensure input expr type is a scalar/vector of type Boolty
23152300
if (CheckScalarOrVector(&SemaRef, TheCall, getASTContext().BoolTy, 0))
23162301
return true;
23172302

23182303
ExprResult A = TheCall->getArg(0);
23192304
QualType ArgTyA = A.get()->getType();
2320-
23212305
// return type is the same as the input type
23222306
TheCall->setType(ArgTyA);
2323-
23242307
break;
23252308
}
23262309
case Builtin::BI__builtin_hlsl_all:

clang/test/CodeGenHLSL/builtins/or.hlsl

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
// RUN: dxil-pc-shadermodel6.3-library %s \
33
// RUN: -emit-llvm -O1 -o - | FileCheck %s
44

5-
//CHECK-LABEL: define noundef i1 @_Z12test_or_boolbb(
5+
//CHECK-LABEL: define noundef i1 @_Z15test_and_scalarbb(
66
//CHECK-SAME: i1 noundef [[X:%.*]], i1 noundef [[Y:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] {
77
//CHECK-NEXT: [[ENTRY:.*:]]
8-
//CHECK-NEXT: [[HLSL_OR:%.*]] = or i1 [[x]], [[y]]
8+
//CHECK-NEXT: [[HLSL_OR:%.*]] = or i1 [[X]], [[Y]]
99
//CHECK-NEXT: ret i1 [[HLSL_OR]]
10-
//CHECK_NEXT: }
10+
//CHECK-NEXT: }
1111
bool test_and_scalar(bool x, bool y)
1212
{
1313
return or(x, y);
@@ -16,9 +16,9 @@ bool test_and_scalar(bool x, bool y)
1616
//CHECK-LABEL: define noundef <2 x i1> @_Z13test_or_bool2Dv2_bS_(
1717
//CHECK-SAME: <2 x i1> noundef [[X:%.*]], <2 x i1> noundef [[Y:%.*]]) local_unnamed_addr #[[ATTR0]] {
1818
//CHECK-NEXT: [[ENTRY:.*:]]
19-
//CHECK-NEXT: [[HLSL_OR:%.*]] = or <2 xi1> [[x]], [[y]]
19+
//CHECK-NEXT: [[HLSL_OR:%.*]] = or <2 x i1> [[X]], [[Y]]
2020
//CHECK-NEXT: ret <2 x i1> [[HLSL_OR]]
21-
//CHECK_NEXT: }
21+
//CHECK-NEXT: }
2222
bool2 test_or_bool2(bool2 x, bool2 y)
2323
{
2424
return or(x, y);
@@ -27,9 +27,9 @@ bool2 test_or_bool2(bool2 x, bool2 y)
2727
//CHECK-LABEL: define noundef <3 x i1> @_Z13test_or_bool3Dv3_bS_(
2828
//CHECK-SAME: <3 x i1> noundef [[X:%.*]], <3 x i1> noundef [[Y:%.*]]) local_unnamed_addr #[[ATTR0]] {
2929
//CHECK-NEXT: [[ENTRY:.*:]]
30-
//CHECK-NEXT: [[HLSL_OR:%.*]] = or <3 xi1> [[x]], [[y]]
30+
//CHECK-NEXT: [[HLSL_OR:%.*]] = or <3 x i1> [[X]], [[Y]]
3131
//CHECK-NEXT: ret <3 x i1> [[HLSL_OR]]
32-
//CHECK_NEXT: }
32+
//CHECK-NEXT: }
3333
bool3 test_or_bool3(bool3 x, bool3 y)
3434
{
3535
return or(x, y);
@@ -38,9 +38,9 @@ bool3 test_or_bool3(bool3 x, bool3 y)
3838
//CHECK-LABEL: define noundef <4 x i1> @_Z13test_or_bool4Dv4_bS_(
3939
//CHECK-SAME: <4 x i1> noundef [[X:%.*]], <4 x i1> noundef [[Y:%.*]]) local_unnamed_addr #[[ATTR0]] {
4040
//CHECK-NEXT: [[ENTRY:.*:]]
41-
//CHECK-NEXT: [[HLSL_OR:%.*]] = or <4 xi1> [[x]], [[y]]
41+
//CHECK-NEXT: [[HLSL_OR:%.*]] = or <4 x i1> [[X]], [[Y]]
4242
//CHECK-NEXT: ret <4 x i1> [[HLSL_OR]]
43-
//CHECK_NEXT: }
43+
//CHECK-NEXT: }
4444
bool4 test_or_bool4(bool4 x, bool4 y)
4545
{
4646
return or(x, y);
@@ -49,10 +49,10 @@ bool4 test_or_bool4(bool4 x, bool4 y)
4949
//CHECK-LABEL: define noundef i1 @_Z11test_or_intii(
5050
//CHECK-SAME: i32 noundef [[X:%.*]], i32 noundef [[Y:%.*]]) local_unnamed_addr #[[ATTR0]] {
5151
//CHECK-NEXT: [[ENTRY:.*:]]
52-
//CHECK_NEXT: [[0:%.*]] = or i32 [[y]], [[x]]
53-
//CHECK-NEXT: [[HLSL_OR:%.*]] = icmp ne i32 [[0]], 0
52+
//CHECK-NEXT: [[A:%.*]] = or i32 [[Y]], [[X]]
53+
//CHECK-NEXT: [[HLSL_OR:%.*]] = icmp ne i32 [[A]], 0
5454
//CHECK-NEXT: ret i1 [[HLSL_OR]]
55-
//CHECK_NEXT: }
55+
//CHECK-NEXT: }
5656
bool test_or_int(int x, int y)
5757
{
5858
return or(x, y);
@@ -61,10 +61,10 @@ bool test_or_int(int x, int y)
6161
//CHECK-LABEL: define noundef <4 x i1> @_Z12test_or_int4Dv4_iS_(
6262
//CHECK-SAME: <4 x i32> noundef [[X:%.*]], <4 x i32> noundef [[Y:%.*]]) local_unnamed_addr #[[ATTR0]] {
6363
//CHECK-NEXT: [[ENTRY:.*:]]
64-
//CHECK_NEXT: [[0:%.*]] = or <4 x i32> [[y]], [[x]]
65-
//CHECK-NEXT: [[HLSL_OR:%.*]] = icmp ne <4 x i32> [[0]], zeroinitializer
64+
//CHECK-NEXT: [[A:%.*]] = or <4 x i32> [[Y]], [[X]]
65+
//CHECK-NEXT: [[HLSL_OR:%.*]] = icmp ne <4 x i32> [[A]], zeroinitializer
6666
//CHECK-NEXT: ret <4 x i1> [[HLSL_OR]]
67-
//CHECK_NEXT: }
67+
//CHECK-NEXT: }
6868
bool4 test_or_int4(int4 x, int4 y)
6969
{
7070
return or(x, y);
@@ -77,8 +77,9 @@ bool4 test_or_int4(int4 x, int4 y)
7777
//CHECK-NEXT: [[TOBOOL1:%.*]] = fcmp reassoc nnan ninf nsz arcp afn une <4 x float> [[Y]], zeroinitializer
7878
//CHECK-NEXT: [[HLSL_OR:%.*]] = or <4 x i1> [[TOBOOL]], [[TOBOOL1]]
7979
//CHECK-NEXT: ret <4 x i1> [[HLSL_OR]]
80-
//CHECK_NEXT: }
80+
//CHECK-NEXT: }
8181
bool4 test_or_float4(float4 x, float4 y)
8282
{
8383
return or(x, y);
8484
}
85+

0 commit comments

Comments
 (0)