-
Notifications
You must be signed in to change notification settings - Fork 13.4k
[HLSL] Overload resolution should promote 16-bit types #81047
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
Labels
Comments
llvm-beanz
added a commit
to llvm-beanz/llvm-project
that referenced
this issue
Feb 7, 2024
This addresses feedback from @rjmcall. The main updates are: * Added asserts and todos about handling constrained intrinsics. * Fixed sufflevector code generation (and updated tests) * Fixed shadowed promotion casts. Writing a test for this revealed another issue. * Added Element conversion to conversion rank checking, and added test to verify promotion is preferred over conversion. * Added HLSL integral promotion check. There are still at least two outstanding bugs that are exposed by this change which I've added an XFAIL'd test for (llvm#81047 & llvm#81049). HLSL's promotion rules are not well written down, but specifically in overload resolution integer and floating point values can implicitly cast to larger types and the smallest of the larger types is the best match.
12 tasks
llvm-beanz
added a commit
to llvm-beanz/llvm-project
that referenced
this issue
Apr 26, 2024
This PR fixes bugs in HLSL floating conversions. HLSL always has `half`, `float` and `double` types, which promote in the order: `half`->`float`->`double` and convert in the order: `double`->`float`->`half` As with other conversions in C++, promotions are preferred over conversions. We do have floating conversions documented in the draft language specification (https://microsoft.github.io/hlsl-specs/specs/hlsl.pdf [Conv.rank.float]) although the exact language is still in flux (microsoft/hlsl-specs#206). Resolves llvm#81047
llvm-beanz
added a commit
that referenced
this issue
May 2, 2024
This PR fixes bugs in HLSL floating conversions. HLSL always has `half`, `float` and `double` types, which promote in the order: `half`->`float`->`double` and convert in the order: `double`->`float`->`half` As with other conversions in C++, promotions are preferred over conversions. We do have floating conversions documented in the draft language specification (https://microsoft.github.io/hlsl-specs/specs/hlsl.pdf [Conv.rank.float]) although the exact language is still in flux (microsoft/hlsl-specs#206). Resolves #81047
@llvm/issue-subscribers-clang-frontend Author: Chris B (llvm-beanz)
In working on #71098, I've discovered a few cases where C++ overload resolution rules don't quite match HLSL. HLSL allows "promotion" casting 16-bit types to larger types, and will select the first larger type that fits. In the following examples both should resolve successfully to the 32-bit overloads:
void Fn3(double2 D);
void Fn3(float2 F);
void Call3(half2 H) {
Fn3(H);
}
void Fn4(int64_t2 L);
void Fn4(int2 I);
void Call4(int16_t H) {
Fn4(H);
} Notes:
Acceptance Criteria
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
In working on #71098, I've discovered a few cases where C++ overload resolution rules don't quite match HLSL. HLSL allows "promotion" casting 16-bit types to larger types, and will select the first larger type that fits. In the following examples both should resolve successfully to the 32-bit overloads:
Notes:
Acceptance Criteria
The text was updated successfully, but these errors were encountered: