[llvm] [SimplifyLibCalls] Constant fold scalbxx (PR #114417)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 8 11:04:07 PST 2024


================
@@ -2621,6 +2623,21 @@ static Constant *ConstantFoldLibCall2(StringRef Name, Type *Ty,
   switch (Func) {
   default:
     break;
+  case LibFunc_ldexp:
+  case LibFunc_ldexpf:
+  case LibFunc_ldexpl:
+  case LibFunc_scalbn:
+  case LibFunc_scalbnf:
+  case LibFunc_scalbnl:
+  case LibFunc_scalbln:
+  case LibFunc_scalblnf:
+  case LibFunc_scalblnl:
+    if (TLI->has(Func)) {
+      APFloat ret =
+          llvm::scalbn(Op1V, Op2V.convertToDouble(), RoundingMode::TowardZero);
----------------
arsenm wrote:

This function is handling binary floating point calls, with 2 FP arguments. This operation does not follow this pattern. This code should be somewhere else. I don't see how this could would be reached as-is. The `dyn_cast<ConstantFP>` should always fail. This should go somewhere else for the FP + int, and match on a ConstantInt operand 

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


More information about the llvm-commits mailing list