-
Notifications
You must be signed in to change notification settings - Fork 14.9k
[HLSL] Convert vectors to bool for unary ! #163857
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
Merged
Merged
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.6-library -disable-llvm-passes -emit-llvm -finclude-default-header -fnative-half-type -o - %s | FileCheck %s | ||
|
||
// CHECK-LABEL: case1 | ||
// CHECK: [[ToBool:%.*]] = icmp ne <2 x i32> {{.*}}, zeroinitializer | ||
// CHECK-NEXT: [[BoolCmp:%.*]] = icmp eq <2 x i1> [[ToBool]], zeroinitializer | ||
// CHECK-NEXT: {{.*}} = zext <2 x i1> [[BoolCmp]] to <2 x i32> | ||
export uint32_t2 case1(uint32_t2 b) { | ||
return !b; | ||
} | ||
|
||
// CHECK-LABEL: case2 | ||
// CHECK: [[ToBool:%.*]] = icmp ne <3 x i32> {{.*}}, zeroinitializer | ||
// CHECK-NEXT: [[BoolCmp:%.*]] = icmp eq <3 x i1> [[ToBool]], zeroinitializer | ||
// CHECK-NEXT: {{.*}} = zext <3 x i1> [[BoolCmp]] to <3 x i32> | ||
export int32_t3 case2(int32_t3 b) { | ||
return !b; | ||
} | ||
|
||
// CHECK-LABEL: case3 | ||
// CHECK: [[ToBool:%.*]] = fcmp reassoc nnan ninf nsz arcp afn une half {{.*}}, 0xH0000 | ||
// CHECK-NEXT: [[BoolCmp:%.*]] = xor i1 [[ToBool]], true | ||
// CHECK-NEXT: {{.*}} = uitofp i1 [[BoolCmp]] to half | ||
export float16_t case3(float16_t b) { | ||
return !b; | ||
} | ||
|
||
// CHECK-LABEL: case4 | ||
// CHECK: [[ToBool:%.*]] = fcmp reassoc nnan ninf nsz arcp afn une <4 x float> {{.*}}, zeroinitializer | ||
// CHECK-NEXT: [[BoolCmp:%.*]] = icmp eq <4 x i1> [[ToBool]], zeroinitializer | ||
// CHECK-NEXT: {{.*}} = uitofp <4 x i1> [[BoolCmp]] to <4 x float> | ||
export float4 case4(float4 b) { | ||
return !b; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// RUN: %clang_cc1 -finclude-default-header -triple dxil-pc-shadermodel6.6-library %s -fnative-half-type -ast-dump -ast-dump-filter=case | FileCheck %s | ||
|
||
// CHECK-LABEL: FunctionDecl {{.*}} used case1 'uint32_t2 (uint32_t2)' | ||
// CHECK-NEXT: ParmVarDecl {{.*}} used b 'uint32_t2':'vector<uint32_t, 2>' | ||
// CHECK-NEXT: CompoundStmt | ||
// CHECK-NEXT: ReturnStmt | ||
// CHECK-NEXT: ImplicitCastExpr {{.*}} 'vector<uint32_t, 2>' <IntegralCast> | ||
// CHECK-NEXT: UnaryOperator {{.*}} 'vector<bool, 2>' prefix '!' cannot overflow | ||
// CHECK-NEXT: ImplicitCastExpr {{.*}} 'vector<bool, 2>' <IntegralToBoolean> | ||
// CHECK-NEXT: ImplicitCastExpr {{.*}} 'uint32_t2':'vector<uint32_t, 2>' <LValueToRValue> | ||
// CHECK-NEXT: DeclRefExpr {{.*}} 'uint32_t2':'vector<uint32_t, 2>' lvalue ParmVar {{.*}} 'b' 'uint32_t2':'vector<uint32_t, 2>' | ||
export uint32_t2 case1(uint32_t2 b) { | ||
return !b; | ||
} | ||
|
||
// CHECK-LABEL: FunctionDecl {{.*}} used case2 'int32_t3 (int32_t3)' | ||
// CHECK-NEXT: ParmVarDecl {{.*}} used b 'int32_t3':'vector<int32_t, 3>' | ||
// CHECK-NEXT: CompoundStmt | ||
// CHECK-NEXT: ReturnStmt | ||
// CHECK-NEXT: ImplicitCastExpr {{.*}} 'vector<int32_t, 3>' <IntegralCast> | ||
// CHECK-NEXT: UnaryOperator {{.*}} 'vector<bool, 3>' prefix '!' cannot overflow | ||
// CHECK-NEXT: ImplicitCastExpr {{.*}} 'vector<bool, 3>' <IntegralToBoolean> | ||
// CHECK-NEXT: ImplicitCastExpr {{.*}} 'int32_t3':'vector<int32_t, 3>' <LValueToRValue> | ||
// CHECK-NEXT: DeclRefExpr {{.*}} 'int32_t3':'vector<int32_t, 3>' lvalue ParmVar {{.*}} 'b' 'int32_t3':'vector<int32_t, 3>' | ||
export int32_t3 case2(int32_t3 b) { | ||
return !b; | ||
} | ||
|
||
// CHECK-LABEL: FunctionDecl {{.*}} used case3 'float16_t (float16_t)' | ||
// CHECK-NEXT: ParmVarDecl {{.*}} used b 'float16_t':'half' | ||
// CHECK-NEXT: CompoundStmt | ||
// CHECK-NEXT: ReturnStmt | ||
// CHECK-NEXT: ImplicitCastExpr {{.*}} 'float16_t':'half' <IntegralToFloating> | ||
// CHECK-NEXT: UnaryOperator {{.*}} 'bool' prefix '!' cannot overflow | ||
// CHECK-NEXT: ImplicitCastExpr {{.*}} 'bool' <FloatingToBoolean> | ||
// CHECK-NEXT: ImplicitCastExpr {{.*}} 'float16_t':'half' <LValueToRValue> | ||
// CHECK-NEXT: DeclRefExpr {{.*}} 'float16_t':'half' lvalue ParmVar {{.*}} 'b' 'float16_t':'half' | ||
export float16_t case3(float16_t b) { | ||
return !b; | ||
} | ||
|
||
// CHECK-LABEL: FunctionDecl {{.*}} used case4 'float4 (float4)' | ||
// CHECK-NEXT: ParmVarDecl {{.*}} used b 'float4':'vector<float, 4>' | ||
// CHECK-NEXT: CompoundStmt | ||
// CHECK-NEXT: ReturnStmt | ||
// CHECK-NEXT: ImplicitCastExpr {{.*}} 'vector<float, 4>' <IntegralToFloating> | ||
// CHECK-NEXT: UnaryOperator {{.*}} 'vector<bool, 4>' prefix '!' cannot overflow | ||
// CHECK-NEXT: ImplicitCastExpr {{.*}} 'vector<bool, 4>' <FloatingToBoolean> | ||
// CHECK-NEXT: ImplicitCastExpr {{.*}} 'float4':'vector<float, 4>' <LValueToRValue> | ||
// CHECK-NEXT: DeclRefExpr {{.*}} 'float4':'vector<float, 4>' lvalue ParmVar {{.*}} 'b' 'float4':'vector<float, 4>' | ||
export float4 case4(float4 b) { | ||
return !b; | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.