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

Justin Bogner via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 12 10:23:41 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()) {
----------------
bogner wrote:

I'm confused about a couple of things here, and it doesn't really look right.
1. hasFloatingRepresentation returns true for any floating point type, but we're explicitly excluding double. Do we really want this to diagnose on double but not for Long Double, BFloat16, or Ibm128?
2. The name of this function is a bit ambiguous - is it supposed to be checking for exactly `float` (as the `ExpectedType` before this change implies) or "any floating point type" (as the use of `hasFloatingRepresentation` implies)? As is it doesn't do either of those things.
3. Why is `ExpectedType` usually `float` but sometimes `half`?
4. I don't think the `half` diagnostic is tested - it should presumably read "passing 'XYZ' to parameter of incompatible type 'half'"

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


More information about the cfe-commits mailing list