-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[HLSL] implement elementwise firstbithigh hlsl builtin #111082
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 all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
d27acf8
implement firstbithigh hlsl builtin
spall 6f2f8eb
make clang format happy
spall eda4743
address PR comments
spall 5836394
update firstbithigh to the correct behavior. both dxil and spirv supp…
spall 3abd4c7
make clang format happy
spall 916d845
switch to unaryBits
spall e6cd0d0
address pr comments
spall 8c087cf
remove use of vectors of length 1 in firstbithigh64 code
spall 05dd187
address pr comments
spall 3464f2e
cast to unsigned
spall d252458
address comment
spall a121e74
fix clang format error
spall 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
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
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,153 @@ | ||
// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \ | ||
// RUN: dxil-pc-shadermodel6.3-library %s -fnative-half-type \ | ||
// RUN: -emit-llvm -disable-llvm-passes -o - | FileCheck %s -DTARGET=dx | ||
// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \ | ||
// RUN: spirv-unknown-vulkan-compute %s -fnative-half-type \ | ||
// RUN: -emit-llvm -disable-llvm-passes \ | ||
// RUN: -o - | FileCheck %s -DTARGET=spv | ||
|
||
#ifdef __HLSL_ENABLE_16_BIT | ||
// CHECK-LABEL: test_firstbithigh_ushort | ||
// CHECK: call i32 @llvm.[[TARGET]].firstbituhigh.i16 | ||
uint test_firstbithigh_ushort(uint16_t p0) { | ||
return firstbithigh(p0); | ||
} | ||
|
||
// CHECK-LABEL: test_firstbithigh_ushort2 | ||
// CHECK: call <2 x i32> @llvm.[[TARGET]].firstbituhigh.v2i16 | ||
uint2 test_firstbithigh_ushort2(uint16_t2 p0) { | ||
return firstbithigh(p0); | ||
} | ||
|
||
// CHECK-LABEL: test_firstbithigh_ushort3 | ||
// CHECK: call <3 x i32> @llvm.[[TARGET]].firstbituhigh.v3i16 | ||
uint3 test_firstbithigh_ushort3(uint16_t3 p0) { | ||
return firstbithigh(p0); | ||
} | ||
|
||
// CHECK-LABEL: test_firstbithigh_ushort4 | ||
// CHECK: call <4 x i32> @llvm.[[TARGET]].firstbituhigh.v4i16 | ||
uint4 test_firstbithigh_ushort4(uint16_t4 p0) { | ||
return firstbithigh(p0); | ||
} | ||
|
||
// CHECK-LABEL: test_firstbithigh_short | ||
// CHECK: call i32 @llvm.[[TARGET]].firstbitshigh.i16 | ||
uint test_firstbithigh_short(int16_t p0) { | ||
return firstbithigh(p0); | ||
} | ||
|
||
// CHECK-LABEL: test_firstbithigh_short2 | ||
// CHECK: call <2 x i32> @llvm.[[TARGET]].firstbitshigh.v2i16 | ||
uint2 test_firstbithigh_short2(int16_t2 p0) { | ||
return firstbithigh(p0); | ||
} | ||
|
||
// CHECK-LABEL: test_firstbithigh_short3 | ||
// CHECK: call <3 x i32> @llvm.[[TARGET]].firstbitshigh.v3i16 | ||
uint3 test_firstbithigh_short3(int16_t3 p0) { | ||
return firstbithigh(p0); | ||
} | ||
|
||
// CHECK-LABEL: test_firstbithigh_short4 | ||
// CHECK: call <4 x i32> @llvm.[[TARGET]].firstbitshigh.v4i16 | ||
uint4 test_firstbithigh_short4(int16_t4 p0) { | ||
return firstbithigh(p0); | ||
} | ||
#endif // __HLSL_ENABLE_16_BIT | ||
|
||
// CHECK-LABEL: test_firstbithigh_uint | ||
// CHECK: call i32 @llvm.[[TARGET]].firstbituhigh.i32 | ||
uint test_firstbithigh_uint(uint p0) { | ||
return firstbithigh(p0); | ||
} | ||
|
||
// CHECK-LABEL: test_firstbithigh_uint2 | ||
// CHECK: call <2 x i32> @llvm.[[TARGET]].firstbituhigh.v2i32 | ||
uint2 test_firstbithigh_uint2(uint2 p0) { | ||
return firstbithigh(p0); | ||
} | ||
|
||
// CHECK-LABEL: test_firstbithigh_uint3 | ||
// CHECK: call <3 x i32> @llvm.[[TARGET]].firstbituhigh.v3i32 | ||
uint3 test_firstbithigh_uint3(uint3 p0) { | ||
return firstbithigh(p0); | ||
} | ||
|
||
// CHECK-LABEL: test_firstbithigh_uint4 | ||
// CHECK: call <4 x i32> @llvm.[[TARGET]].firstbituhigh.v4i32 | ||
uint4 test_firstbithigh_uint4(uint4 p0) { | ||
return firstbithigh(p0); | ||
} | ||
|
||
// CHECK-LABEL: test_firstbithigh_ulong | ||
// CHECK: call i32 @llvm.[[TARGET]].firstbituhigh.i64 | ||
uint test_firstbithigh_ulong(uint64_t p0) { | ||
return firstbithigh(p0); | ||
} | ||
|
||
// CHECK-LABEL: test_firstbithigh_ulong2 | ||
// CHECK: call <2 x i32> @llvm.[[TARGET]].firstbituhigh.v2i64 | ||
uint2 test_firstbithigh_ulong2(uint64_t2 p0) { | ||
return firstbithigh(p0); | ||
} | ||
|
||
// CHECK-LABEL: test_firstbithigh_ulong3 | ||
// CHECK: call <3 x i32> @llvm.[[TARGET]].firstbituhigh.v3i64 | ||
uint3 test_firstbithigh_ulong3(uint64_t3 p0) { | ||
return firstbithigh(p0); | ||
} | ||
|
||
// CHECK-LABEL: test_firstbithigh_ulong4 | ||
// CHECK: call <4 x i32> @llvm.[[TARGET]].firstbituhigh.v4i64 | ||
uint4 test_firstbithigh_ulong4(uint64_t4 p0) { | ||
return firstbithigh(p0); | ||
} | ||
|
||
// CHECK-LABEL: test_firstbithigh_int | ||
// CHECK: call i32 @llvm.[[TARGET]].firstbitshigh.i32 | ||
uint test_firstbithigh_int(int p0) { | ||
return firstbithigh(p0); | ||
} | ||
|
||
// CHECK-LABEL: test_firstbithigh_int2 | ||
// CHECK: call <2 x i32> @llvm.[[TARGET]].firstbitshigh.v2i32 | ||
uint2 test_firstbithigh_int2(int2 p0) { | ||
return firstbithigh(p0); | ||
} | ||
|
||
// CHECK-LABEL: test_firstbithigh_int3 | ||
// CHECK: call <3 x i32> @llvm.[[TARGET]].firstbitshigh.v3i32 | ||
uint3 test_firstbithigh_int3(int3 p0) { | ||
return firstbithigh(p0); | ||
} | ||
|
||
// CHECK-LABEL: test_firstbithigh_int4 | ||
// CHECK: call <4 x i32> @llvm.[[TARGET]].firstbitshigh.v4i32 | ||
uint4 test_firstbithigh_int4(int4 p0) { | ||
return firstbithigh(p0); | ||
} | ||
|
||
// CHECK-LABEL: test_firstbithigh_long | ||
// CHECK: call i32 @llvm.[[TARGET]].firstbitshigh.i64 | ||
uint test_firstbithigh_long(int64_t p0) { | ||
return firstbithigh(p0); | ||
} | ||
|
||
// CHECK-LABEL: test_firstbithigh_long2 | ||
// CHECK: call <2 x i32> @llvm.[[TARGET]].firstbitshigh.v2i64 | ||
uint2 test_firstbithigh_long2(int64_t2 p0) { | ||
return firstbithigh(p0); | ||
} | ||
|
||
// CHECK-LABEL: test_firstbithigh_long3 | ||
// CHECK: call <3 x i32> @llvm.[[TARGET]].firstbitshigh.v3i64 | ||
uint3 test_firstbithigh_long3(int64_t3 p0) { | ||
return firstbithigh(p0); | ||
} | ||
|
||
// CHECK-LABEL: test_firstbithigh_long4 | ||
// CHECK: call <4 x i32> @llvm.[[TARGET]].firstbitshigh.v4i64 | ||
uint4 test_firstbithigh_long4(int64_t4 p0) { | ||
return firstbithigh(p0); | ||
} |
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,28 @@ | ||
// RUN: %clang_cc1 -finclude-default-header -triple dxil-pc-shadermodel6.6-library %s -fnative-half-type -emit-llvm-only -disable-llvm-passes -verify -verify-ignore-unexpected | ||
|
||
int test_too_few_arg() { | ||
return firstbithigh(); | ||
// expected-error@-1 {{no matching function for call to 'firstbithigh'}} | ||
} | ||
|
||
int test_too_many_arg(int p0) { | ||
return firstbithigh(p0, p0); | ||
// expected-error@-1 {{no matching function for call to 'firstbithigh'}} | ||
} | ||
|
||
double test_int_builtin(double p0) { | ||
return firstbithigh(p0); | ||
// expected-error@-1 {{call to 'firstbithigh' is ambiguous}} | ||
} | ||
|
||
double2 test_int_builtin_2(double2 p0) { | ||
return __builtin_hlsl_elementwise_firstbithigh(p0); | ||
// expected-error@-1 {{1st argument must be a vector of integers | ||
// (was 'double2' (aka 'vector<double, 2>'))}} | ||
} | ||
|
||
float test_int_builtin_3(float p0) { | ||
return __builtin_hlsl_elementwise_firstbithigh(p0); | ||
// expected-error@-1 {{1st argument must be a vector of integers | ||
// (was 'float')}} | ||
} |
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
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
Oops, something went wrong.
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.