[llvm] [VPlan] Optimize FindLast of (binop %IV, live-in) by sinking. (PR #183911)
Mel Chen via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 12 03:11:58 PDT 2026
================
@@ -5650,6 +5650,40 @@ void VPlanTransforms::addExitUsersForFirstOrderRecurrences(VPlan &Plan,
}
}
+/// Check if \p V is a binary expression of a widened IV and a loop-invariant
+/// value. Returns the widened IV if found, nullptr otherwise.
+static VPWidenIntOrFpInductionRecipe *getExpressionIV(VPValue *V) {
+ auto *BinOp = dyn_cast<VPWidenRecipe>(V);
+ if (!BinOp || !Instruction::isBinaryOp(BinOp->getOpcode()))
+ return nullptr;
+
+ VPValue *Op0 = BinOp->getOperand(0);
+ VPValue *Op1 = BinOp->getOperand(1);
+ if (!isa<VPWidenIntOrFpInductionRecipe>(Op0))
+ std::swap(Op0, Op1);
+
+ if (!Op1->isDefinedOutsideLoopRegions())
+ return nullptr;
----------------
Mel-Chen wrote:
This makes me wonder if running this optimization after LICM might work better.
https://github.com/llvm/llvm-project/pull/183911
More information about the llvm-commits
mailing list