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

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Sun Jan 5 21:13:44 PST 2025


================
@@ -4052,7 +4098,26 @@ 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<CallInst>(Agg)) {
+      if (Function *F = FrexpCall->getCalledFunction()) {
+        if (F->getIntrinsicID() == Intrinsic::frexp) {
----------------
arsenm wrote:

dyn_cast to IntrinsicInst and it will simplify this a little 

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


More information about the llvm-commits mailing list