[llvm] [InstCombine] Lower ilogb to bit operations for normal values (PR #218044)

via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 24 06:04:27 PDT 2026


================
@@ -3239,6 +3239,59 @@ Value *LibCallSimplifier::optimizeFdim(CallInst *CI, IRBuilderBase &B) {
   return ConstantFP::get(CI->getType(), Difference);
 }
 
+Value *LibCallSimplifier::optimizeILogB(CallInst *CI, IRBuilderBase &B) {
+  // Prevent the optimization from re-triggering and causing the fixpoint error.
+  if (CI->use_empty())
+    return nullptr;
+
+  Value *X = CI->getArgOperand(0);
+  Type *FTy = X->getType();
+
+  // Restricted to standard IEEE floats, doubles and fp128
+  if (!FTy->isFloatTy() && !FTy->isDoubleTy() && !FTy->isFP128Ty())
----------------
tadeuszjt wrote:

Please clarify, do you mean a test in ilogb.ll  which ensures the optimization doesn't run on fp80 and PPC or that I should add the logic for those types here?

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


More information about the llvm-commits mailing list