[clang] [HLSL] Shore up floating point conversions (PR #90222)

Chris B via cfe-commits cfe-commits at lists.llvm.org
Wed May 1 12:26:32 PDT 2024


================
@@ -4393,6 +4401,24 @@ getFixedEnumPromtion(Sema &S, const StandardConversionSequence &SCS) {
   return FixedEnumPromotion::ToPromotedUnderlyingType;
 }
 
+static ImplicitConversionSequence::CompareKind
+HLSLCompareFloatingRank(QualType LHS, QualType RHS) {
+  assert(LHS->isVectorType() == RHS->isVectorType() &&
----------------
llvm-beanz wrote:

I'm not yet handling scalar -> vector conversions. That won't change this code, but it will add extra handling in the `CompareStandardConversionSequences` function because we'll need to prefer scalar->vector conversions when the element type is the same (and maybe a promotion).

We don't yet generate the cast sequences for the scalar->vector conversions, so we can't yet handle them.

For context what this is doing: during overload resolution a list of candidate functions is generated by iterating over each possible function and generating possible conversion sequences for each overload. Then each conversion sequence is evaluated against the other to determine if it is better or worse to choose which overload we want. This code just extends that to allow floating point promotions and conversions more freely than C does, and uses the same logic for vector element conversions. 

https://github.com/llvm/llvm-project/pull/90222


More information about the cfe-commits mailing list