================
@@ -14574,9 +14574,17 @@ bool FloatExprEvaluator::VisitCallExpr(const CallExpr 
*E) {
   default:
     return false;
 
+  case Builtin::BI__builtin_frexpl:
+    // AIX library function `frexpl` has 'long double' type and not
+    // PPCDoubleDouble type. To make sure we generate the right value, don't
+    // constant evaluate it and instead defer to a libcall.
+    if (Info.Ctx.getTargetInfo().getTriple().isPPC() &&
+        (&Info.Ctx.getTargetInfo().getLongDoubleFormat() !=
+         &llvm::APFloat::PPCDoubleDouble()))
+      return false;
+    LLVM_FALLTHROUGH;
   case Builtin::BI__builtin_frexp:
-  case Builtin::BI__builtin_frexpf:
-  case Builtin::BI__builtin_frexpl: {
+  case Builtin::BI__builtin_frexpf: {
----------------
zahiraam wrote:

> > With this change (special casing frexpl for AIX) the IR produced is: `call 
> > { double, i32 } @llvm.frexp.f64.i32(double 1.234500e+02)`
> > without this change the IR is: `store double 0.000000e+00, ptr 
> > %returnValue, align 8`
> > This doesn't seem correct to me.
> 
> Ignoring considerations around storing to `DummyInt`, the original test code 
> was:
> 
> ```
>   returnValue = __builtin_frexpl(0.0L, &DummyInt);
> ```
> 
> I don't know where the `123.45` came from. That the result is zero for an 
> input of zero is correct; however, the constant-folding in the context of 
> that test would undermine its intent (see check that an appropriate target 
> runtime function is called).

Sorry. The output is:   `call { double, i32 } @llvm.frexp.f64.i32(double 
0.000000e+00)`. That was a mistake of my part.

https://github.com/llvm/llvm-project/pull/88978
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to