[llvm] [InstCombine] Fix `frexp(frexp(x)) -> frexp(x)` fold (PR #138837)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Wed May 7 02:51:04 PDT 2025


================
@@ -3799,6 +3799,18 @@ Instruction *InstCombinerImpl::visitCallInst(CallInst &CI) {
     }
     break;
   }
+  case Intrinsic::frexp: {
+    Value *X;
+    // Frexp is idempotent with the added complication of the struct return.
+    if (match(II->getArgOperand(0), m_ExtractValue<0>(m_Value(X)))) {
+      if (match(X, m_Intrinsic<Intrinsic::frexp>(m_Value()))) {
+        X = Builder.CreateInsertValue(
+            X, ConstantInt::get(II->getType()->getStructElementType(1), 0), 1);
----------------
arsenm wrote:

Constant::getNullValue? 

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


More information about the llvm-commits mailing list