-
Notifications
You must be signed in to change notification settings - Fork 35
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
Simplify conversion sequences and overload scoring #261
Merged
llvm-beanz
merged 5 commits into
microsoft:main
from
llvm-beanz:cbieneman/conversion-simplification
Jun 25, 2024
Merged
Simplify conversion sequences and overload scoring #261
llvm-beanz
merged 5 commits into
microsoft:main
from
llvm-beanz:cbieneman/conversion-simplification
Jun 25, 2024
Conversation
This file contains 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 change is a shift in how conversion sequences and overload scoring is handled to disambiguate a few cases that DXC handles today through simpler rules. The main cases relate to scoring conversion sequences with dimension adjustment conversions. With this change an implicit conversion sequence is now defined as: * Value conversion (lvalue to rvalue or array decay) * Data conversion (int/float/bool/struct promotion or conversion) * Dimension conversion (splat or truncate) * CV qualifier conversion (add const) Conversion sequences are still assigned the rank of their "highest" conversion following the same chart as before where the ranks are: * Exact Match * Extension * Promotion * Conversion * Truncation There is an added rule that if two conversion sequences are both of rank *Promotion* or "Conversion" and one contains an *Extension* but the other does not, the conversion without the *Extension* is the better conversion sequence. Given these rules: ICS(float -> double) > ICS(float -> double3) ICS(float -> double3) > ICS(float -> half) ICS(float -> double2) == ICS(float -> dobule3) ICS(float -> half) > ICS(float -> half3) ICS(float4 -> double3) > ICS(float4 -> half3) ICS(float4 -> double4) > ICS(float4 -> float2) ICS(float4 -> half4) > ICS(float4 -> float2)
This updates the ordering of conversion ranks and disambiguation rule to handle a few more cases: ICS(float -> double) > ICS(float -> float3) ICS(float -> float3) > ICS(float -> double3) ICS(float -> double4) > ICS(float -> half4) ICS(float -> double4) != ICS(float -> double3) ICS(double -> float4) != ICS(double -> float3) ICS(double -> float4) != ICS(double -> half3) ICS(float4 -> float3) > ICS(float4 -> double3) ICS(float4 -> float3) > ICS(float4 -> half3) ICS(float4 -> double3) > ICS(float4 -> half3) ICS(double4 -> float3) != ICS(double4 ->half3) ICS(half4 -> float3) != ICS(half4 ->double3)
bogner
approved these changes
Jun 18, 2024
hekota
approved these changes
Jun 18, 2024
It is no longer relevant
llvm-beanz
added a commit
to llvm/llvm-project
that referenced
this pull request
Jul 13, 2024
This PR reworks HLSL's implicit conversion sequences. Initially I was seeking to match DXC's behavior more closely, but that was leading to a pile of special case rules to tie-break ambiguous cases that should really be left as ambiguous. We've decided that we're going to break compatibility with DXC here, and we may port this new behavior over to DXC instead. This change is a bit closer to C++'s overload resolution rules, but it does have a bit of nuance around how dimension adjustment conversions are ranked. Conversion sequence ranks for HLSL are: * Exact match * Scalar Widening (i.e. splat) * Promotion * Scalar Widening with Promotion * Conversion * Scalar Widening with Conversion * Dimension Reduction (i.e. truncation) * Dimension Reduction with Promotion * Dimension Reduction with Conversion In this implementation I've folded the disambiguation into the conversion sequence ranks which does add some complexity as compared to C++, however this avoids needing to add special casing in `CompareStandardConversionSequences`. I believe the added conversion rank values provide a simpler approach, but feedback is appreciated. The HLSL language spec updates are in the PR here: microsoft/hlsl-specs#261
aaryanshukla
pushed a commit
to aaryanshukla/llvm-project
that referenced
this pull request
Jul 14, 2024
This PR reworks HLSL's implicit conversion sequences. Initially I was seeking to match DXC's behavior more closely, but that was leading to a pile of special case rules to tie-break ambiguous cases that should really be left as ambiguous. We've decided that we're going to break compatibility with DXC here, and we may port this new behavior over to DXC instead. This change is a bit closer to C++'s overload resolution rules, but it does have a bit of nuance around how dimension adjustment conversions are ranked. Conversion sequence ranks for HLSL are: * Exact match * Scalar Widening (i.e. splat) * Promotion * Scalar Widening with Promotion * Conversion * Scalar Widening with Conversion * Dimension Reduction (i.e. truncation) * Dimension Reduction with Promotion * Dimension Reduction with Conversion In this implementation I've folded the disambiguation into the conversion sequence ranks which does add some complexity as compared to C++, however this avoids needing to add special casing in `CompareStandardConversionSequences`. I believe the added conversion rank values provide a simpler approach, but feedback is appreciated. The HLSL language spec updates are in the PR here: microsoft/hlsl-specs#261
aaryanshukla
pushed a commit
to aaryanshukla/llvm-project
that referenced
this pull request
Jul 16, 2024
This PR reworks HLSL's implicit conversion sequences. Initially I was seeking to match DXC's behavior more closely, but that was leading to a pile of special case rules to tie-break ambiguous cases that should really be left as ambiguous. We've decided that we're going to break compatibility with DXC here, and we may port this new behavior over to DXC instead. This change is a bit closer to C++'s overload resolution rules, but it does have a bit of nuance around how dimension adjustment conversions are ranked. Conversion sequence ranks for HLSL are: * Exact match * Scalar Widening (i.e. splat) * Promotion * Scalar Widening with Promotion * Conversion * Scalar Widening with Conversion * Dimension Reduction (i.e. truncation) * Dimension Reduction with Promotion * Dimension Reduction with Conversion In this implementation I've folded the disambiguation into the conversion sequence ranks which does add some complexity as compared to C++, however this avoids needing to add special casing in `CompareStandardConversionSequences`. I believe the added conversion rank values provide a simpler approach, but feedback is appreciated. The HLSL language spec updates are in the PR here: microsoft/hlsl-specs#261
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This change is a shift in how conversion sequences and overload scoring
is handled to disambiguate a few cases that DXC handles today through
simpler rules.
The main cases relate to scoring conversion sequences with dimension
adjustment conversions. With this change an implicit conversion sequence
is now defined as:
Conversion sequences are still assigned the rank of their "highest"
conversion following the same chart as before where the ranks are:
Given these rules:
ICS(float -> double) > ICS(float -> double3)
ICS(float -> double3) > ICS(float -> half)
ICS(float -> double2) == ICS(float -> dobule3)
ICS(float -> half) > ICS(float -> half3)
ICS(float4 -> double3) > ICS(float4 -> half3)
ICS(float4 -> double4) > ICS(float4 -> float2)
ICS(float4 -> half4) > ICS(float4 -> float2)
ICS(float -> double) > ICS(float -> float3)
ICS(float -> float3) > ICS(float -> double3)
ICS(float -> double4) > ICS(float -> half4)
ICS(float -> double4) != ICS(float -> double3)
ICS(double -> float4) != ICS(double -> float3)
ICS(double -> float4) != ICS(double -> half3)
ICS(float4 -> float3) > ICS(float4 -> double3)
ICS(float4 -> float3) > ICS(float4 -> half3)
ICS(float4 -> double3) > ICS(float4 -> half3)
ICS(double4 -> float3) != ICS(double4 ->half3)
ICS(half4 -> float3) != ICS(half4 ->double3)