[clang] [llvm] [DXIL] `exp`, `any`, `lerp`, & `rcp` Intrinsic Lowering (PR #84526)

Farzon Lotfi via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 12 11:02:24 PDT 2024


================
@@ -5254,7 +5250,11 @@ bool CheckAllArgsHaveFloatRepresentation(Sema *S, CallExpr *TheCall) {
   QualType ExpectedType = S->Context.FloatTy;
   for (unsigned i = 0; i < TheCall->getNumArgs(); ++i) {
     QualType PassedType = TheCall->getArg(i)->getType();
-    if (!PassedType->hasFloatingRepresentation()) {
+    ExpectedType = PassedType->isHalfType() && S->getLangOpts().NativeHalfType
+                       ? S->Context.HalfTy
+                       : S->Context.FloatTy;
+    if (PassedType == S->Context.DoubleTy ||
+        !PassedType->hasFloatingRepresentation()) {
----------------
farzonl wrote:

1. This was originally just a check to make sure args were floats and I shoehorned in the double case to handle the type promotions caused by `DefaultVariadicArgumentPromotion` when calling the builtin directly. There are no type promotions for BFloat16 or Ibm128  and we don't define those types in hlsl so i'm not able to test for these other floating point types.
2. The name should probably change.
3. I was hoping to avoid triggering the error on api calls of half\vector<half>  ie. lerp(half,half,half).  There is likely a better way for me to structure this to make it look more correct.
4. It can't be tested I added a test for it on line 91 of `lerp-builtin.hlsl` and the original type is lost by the time we call the builtin. I added a note to explain why it was `float` and not  `half`.



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


More information about the llvm-commits mailing list