[llvm] [ConstantFold] Fold `ilogb` and `ilogbf` when the input parameter is a constant value. (PR #113014)

via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 18 22:04:53 PDT 2024


================
@@ -2391,6 +2405,11 @@ static Constant *ConstantFoldScalarCall1(StringRef Name,
         // TODO: What about hosts that lack a C99 library?
         return ConstantFoldFP(log10, APF, Ty);
       break;
+    case LibFunc_ilogb:
+    case LibFunc_ilogbf:
+      if (!APF.isZero() && TLI->has(Func))
+        return ConstantFoldInt(ilogb, APF, Ty);
----------------
c8ef wrote:

Good idea!

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


More information about the llvm-commits mailing list