-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[HLSL] Implement the 'and' HLSL function #127098
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
e78176b
3aff536
f8f728a
49d0ccf
f4c6443
26fe3fe
2002952
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 5 | ||
// RUN: %clang_cc1 -finclude-default-header -triple \ | ||
// RUN: dxil-pc-shadermodel6.3-library %s \ | ||
// RUN: -emit-llvm -O1 -o - | FileCheck %s | ||
|
||
// CHECK-LABEL: define noundef i1 @_Z15test_and_scalarbb( | ||
// CHECK-SAME: i1 noundef [[X:%.*]], i1 noundef [[Y:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] { | ||
// CHECK-NEXT: [[ENTRY:.*:]] | ||
// CHECK-NEXT: [[HLSL_AND:%.*]] = and i1 [[X]], [[Y]] | ||
// CHECK-NEXT: ret i1 [[HLSL_AND]] | ||
// | ||
bool test_and_scalar(bool x, bool y) { | ||
return and(x, y); | ||
} | ||
|
||
// CHECK-LABEL: define noundef <2 x i1> @_Z14test_and_bool2Dv2_bS_( | ||
// CHECK-SAME: <2 x i1> noundef [[X:%.*]], <2 x i1> noundef [[Y:%.*]]) local_unnamed_addr #[[ATTR0]] { | ||
// CHECK-NEXT: [[ENTRY:.*:]] | ||
// CHECK-NEXT: [[HLSL_AND:%.*]] = and <2 x i1> [[X]], [[Y]] | ||
// CHECK-NEXT: ret <2 x i1> [[HLSL_AND]] | ||
// | ||
bool2 test_and_bool2(bool2 x, bool2 y) { | ||
return and(x, y); | ||
} | ||
|
||
// CHECK-LABEL: define noundef <3 x i1> @_Z14test_and_bool3Dv3_bS_( | ||
// CHECK-SAME: <3 x i1> noundef [[X:%.*]], <3 x i1> noundef [[Y:%.*]]) local_unnamed_addr #[[ATTR0]] { | ||
// CHECK-NEXT: [[ENTRY:.*:]] | ||
// CHECK-NEXT: [[HLSL_AND:%.*]] = and <3 x i1> [[X]], [[Y]] | ||
// CHECK-NEXT: ret <3 x i1> [[HLSL_AND]] | ||
// | ||
bool3 test_and_bool3(bool3 x, bool3 y) { | ||
return and(x, y); | ||
} | ||
|
||
// CHECK-LABEL: define noundef <4 x i1> @_Z14test_and_bool4Dv4_bS_( | ||
// CHECK-SAME: <4 x i1> noundef [[X:%.*]], <4 x i1> noundef [[Y:%.*]]) local_unnamed_addr #[[ATTR0]] { | ||
// CHECK-NEXT: [[ENTRY:.*:]] | ||
// CHECK-NEXT: [[HLSL_AND:%.*]] = and <4 x i1> [[X]], [[Y]] | ||
// CHECK-NEXT: ret <4 x i1> [[HLSL_AND]] | ||
// | ||
bool4 test_and_bool4(bool4 x, bool4 y) { | ||
return and(x, y); | ||
} | ||
|
||
// CHECK-LABEL: define noundef <4 x i1> @_Z13test_and_int4Dv4_iS_( | ||
// CHECK-SAME: <4 x i32> noundef [[X:%.*]], <4 x i32> noundef [[Y:%.*]]) local_unnamed_addr #[[ATTR0]] { | ||
// CHECK-NEXT: [[ENTRY:.*:]] | ||
// CHECK-NEXT: [[TOBOOL:%.*]] = icmp ne <4 x i32> [[X]], zeroinitializer | ||
// CHECK-NEXT: [[TOBOOL1:%.*]] = icmp ne <4 x i32> [[Y]], zeroinitializer | ||
// CHECK-NEXT: [[HLSL_AND:%.*]] = and <4 x i1> [[TOBOOL]], [[TOBOOL1]] | ||
// CHECK-NEXT: ret <4 x i1> [[HLSL_AND]] | ||
// | ||
bool4 test_and_int4(int4 x, int4 y) { | ||
return and(x, y); | ||
} | ||
|
||
// CHECK-LABEL: define noundef <4 x i1> @_Z15test_and_float4Dv4_fS_( | ||
// CHECK-SAME: <4 x float> noundef nofpclass(nan inf) [[X:%.*]], <4 x float> noundef nofpclass(nan inf) [[Y:%.*]]) local_unnamed_addr #[[ATTR0]] { | ||
// CHECK-NEXT: [[ENTRY:.*:]] | ||
// CHECK-NEXT: [[TOBOOL:%.*]] = fcmp reassoc nnan ninf nsz arcp afn une <4 x float> [[X]], zeroinitializer | ||
// CHECK-NEXT: [[TOBOOL1:%.*]] = fcmp reassoc nnan ninf nsz arcp afn une <4 x float> [[Y]], zeroinitializer | ||
// CHECK-NEXT: [[HLSL_AND:%.*]] = and <4 x i1> [[TOBOOL]], [[TOBOOL1]] | ||
// CHECK-NEXT: ret <4 x i1> [[HLSL_AND]] | ||
// | ||
bool4 test_and_float4(float4 x, float4 y) { | ||
return and(x, y); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// RUN: %clang_cc1 -finclude-default-header -triple \ | ||
// RUN: dxil-pc-shadermodel6.3-library %s \ | ||
// RUN: -emit-llvm -O1 -verify | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like this testcase will write to the current directory. This may potentially be write protected and should be avoided. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I will make a PR to fix this |
||
|
||
bool test_too_few_arg(bool a) { | ||
return __builtin_hlsl_and(a); | ||
// expected-error@-1 {{too few arguments to function call, expected 2, have 1}} | ||
} | ||
|
||
bool test_too_many_arg(bool a) { | ||
return __builtin_hlsl_and(a, a, a); | ||
// expected-error@-1 {{too many arguments to function call, expected 2, have 3}} | ||
} | ||
|
||
bool2 test_mismatched_args(bool2 a, bool3 b) { | ||
return __builtin_hlsl_and(a, b); | ||
// expected-error@-1 {{all arguments to '__builtin_hlsl_and' must have the same type}} | ||
} | ||
|
||
bool test_incorrect_type(int a) { | ||
return __builtin_hlsl_and(a, a); | ||
// expected-error@-1{{invalid operand of type 'int' where 'bool' or a vector of such type is required}} | ||
} |
Uh oh!
There was an error while loading. Please reload this page.