[llvm] [VPlan] Optimize FindLast of (binop %IV, live-in) by sinking. (PR #183911)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 3 15:13:02 PST 2026
================
@@ -5664,6 +5663,43 @@ 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, VPRegionBlock *VectorLoopRegion) {
+ auto *BinOp = dyn_cast<VPWidenRecipe>(V);
+ if (!BinOp || !Instruction::isBinaryOp(BinOp->getOpcode()))
+ return nullptr;
+
+ VPWidenIntOrFpInductionRecipe *WideIV = nullptr;
+ for (VPValue *Op : BinOp->operands()) {
+ // Operands must be a single IV and others must be loop invariant.
+ auto *Cand = dyn_cast<VPWidenIntOrFpInductionRecipe>(Op);
+ if (Cand) {
+ if (WideIV)
+ return nullptr;
+ WideIV = Cand;
+ continue;
+ }
+ if (!Op->isDefinedOutsideLoopRegions())
+ return nullptr;
+ }
+ return WideIV;
+}
+
+/// Create a scalar version of the binary op \p V in the middle block,
----------------
fhahn wrote:
updated thanks
https://github.com/llvm/llvm-project/pull/183911
More information about the llvm-commits
mailing list