[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:46 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) {
+ if (auto *SelInst =
+ dyn_cast<SelectInst>(FrexpCall->getArgOperand(0))) {
+ if (isa<ConstantFP>(SelInst->getTrueValue()) ||
+ isa<ConstantFP>(SelInst->getFalseValue())) {
+ Builder.SetInsertPoint(&EV);
----------------
arsenm wrote:
Don't pre-check the conditions or adjust the insert point here. Everything belongs in the foldFrexpOfSelect implementation
https://github.com/llvm/llvm-project/pull/121227
More information about the llvm-commits
mailing list