-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[HLSL] Reapply Move length support out of the DirectX Backend (#121611) #122337
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
Conversation
farzonl
commented
Jan 9, 2025
- attribute keeps getting deleted on bad rebases
@llvm/pr-subscribers-llvm-ir @llvm/pr-subscribers-backend-x86 Author: Farzon Lotfi (farzonl) Changes
Full diff: https://github.com/llvm/llvm-project/pull/122337.diff 1 Files Affected:
diff --git a/clang/lib/Headers/hlsl/hlsl_intrinsics.h b/clang/lib/Headers/hlsl/hlsl_intrinsics.h
index cf287e598f76ba..7105d83078a9d7 100644
--- a/clang/lib/Headers/hlsl/hlsl_intrinsics.h
+++ b/clang/lib/Headers/hlsl/hlsl_intrinsics.h
@@ -1297,9 +1297,11 @@ float4 lerp(float4, float4, float4);
///
/// Length is based on the following formula: sqrt(x[0]^2 + x[1]^2 + ...).
+_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
const inline half length(half X) { return __detail::length_impl(X); }
const inline float length(float X) { return __detail::length_impl(X); }
+_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
template <int N> const inline half length(vector<half, N> X) {
return __detail::length_vec_impl(X);
}
|
@llvm/pr-subscribers-clang Author: Farzon Lotfi (farzonl) Changes
Full diff: https://github.com/llvm/llvm-project/pull/122337.diff 1 Files Affected:
diff --git a/clang/lib/Headers/hlsl/hlsl_intrinsics.h b/clang/lib/Headers/hlsl/hlsl_intrinsics.h
index cf287e598f76ba..7105d83078a9d7 100644
--- a/clang/lib/Headers/hlsl/hlsl_intrinsics.h
+++ b/clang/lib/Headers/hlsl/hlsl_intrinsics.h
@@ -1297,9 +1297,11 @@ float4 lerp(float4, float4, float4);
///
/// Length is based on the following formula: sqrt(x[0]^2 + x[1]^2 + ...).
+_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
const inline half length(half X) { return __detail::length_impl(X); }
const inline float length(float X) { return __detail::length_impl(X); }
+_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
template <int N> const inline half length(vector<half, N> X) {
return __detail::length_vec_impl(X);
}
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this fix a test failure?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, assuming we don't need the other availability denoted
@@ -1297,9 +1297,11 @@ float4 lerp(float4, float4, float4); | |||
/// | |||
/// Length is based on the following formula: sqrt(x[0]^2 + x[1]^2 + ...). | |||
|
|||
_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2) | |||
const inline half length(half X) { return __detail::length_impl(X); } | |||
const inline float length(float X) { return __detail::length_impl(X); } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need _HLSL_AVAILABILITY(shadermodel, 6.2)
on the none half variants?
No failures. We would need to have tests for all intrinsics that if its not SM 6.2 or greater uses of half would error, but we never did that for any of the other intrinsics so we should probably discuss what the test coverage should be and apply it broadly. |
## Changes - Delete DirectX length intrinsic - Delete HLSL length lang builtin - Implement length algorithm entirely in the header. ## History - In the past if an HLSL intrinsic lowered to either a spirv op code or a DXIL opcode we represented it with intrinsics ## Why we are moving away? - To make HLSL apis more portable the team decided that it makes sense for some intrinsics to be defined only in the header. - Since there tends to be more SPIRV opcodes than DXIL opcodes the plan is to support SPIRV opcodes either with target specific builtins or via pattern matching.
0f0b75d
to
6f2da80
Compare
- attribute keeps getting deleted on bad rebases
6f2da80
to
7173a48
Compare
✅ With the latest revision this PR passed the C/C++ code formatter. |
In practice these are pretty tricky to test on just Clang because the 6.2 attribute only applies when -enable-16bit-types is set, which requires shader model 6.2 or greater. So you shouldn't actually be able to make the compiler fail this. The point of the attribute is really just for header completeness so that we can drive documentation and LSP tooling from it. |
@llvm-beanz I'm really confused what is going on here
BUT its failing in buildkite and on other llvm builders. I'm not sure what could do this. |
I figured out what is going on here. On some platforms the loop unroll isn't working This warning shows up:
And there is a I'm switching to define length as |
…to fix test break.
Ok going to try to merge again. no more test failure for length.hlsl in buildkite. only failing test was: |
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/16/builds/11794 Here is the relevant piece of the build log for the reference
|
…21611) (llvm#122337) ## Changes - Delete DirectX length intrinsic - Delete HLSL length lang builtin - Implement length algorithm entirely in the header. ## History - In the past if an HLSL intrinsic lowered to either a spirv op code or a DXIL opcode we represented it with intrinsics ## Why we are moving away? - To make HLSL apis more portable the team decided that it makes sense for some intrinsics to be defined only in the header. - Since there tends to be more SPIRV opcodes than DXIL opcodes the plan is to support SPIRV opcodes either with target specific builtins or via pattern matching.