[llvm] [InstCombine] InstCombine should fold frexp of select to select of frexp (PR #121227)

via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 9 10:25:05 PST 2025


================
@@ -4052,7 +4104,18 @@ Instruction *InstCombinerImpl::visitExtractValueInst(ExtractValueInst &EV) {
   if (Value *V = simplifyExtractValueInst(Agg, EV.getIndices(),
                                           SQ.getWithInstruction(&EV)))
     return replaceInstUsesWith(EV, V);
-
+  if (EV.getNumIndices() == 1 && EV.getIndices()[0] == 0) {
+    if (auto *FrexpCall = dyn_cast<IntrinsicInst>(Agg)) {
+      if (FrexpCall->getIntrinsicID() == Intrinsic::frexp) {
----------------
vortex73 wrote:

> You can use match(&EV, m_ExtractValue<0>(m_Intrinsic<Intrinsic::frexp>(SelInst))) instead.

I may have misunderstood but this won't work since match is a free function expecting a Value and not a `SelectInst` .

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


More information about the llvm-commits mailing list