From ba69e33e13e41481cd9eca1ab31c90058896fffa Mon Sep 17 00:00:00 2001 From: Florian Hahn Date: Thu, 9 Oct 2025 22:03:13 +0100 Subject: [LV] Consistently apply address def scalarization across loop. Consistently scalarize loads used as part of address computations across all uses in the loop. This aligns the VPlan and legacy cost model and fixes a divergence crash. It doesn't matter if the load and address users are in different blocks, as long as they are in the same loop, the scalar value can be used. This removes a number of insert/extracts. --- llvm/lib/Transforms/Vectorize/LoopVectorize.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'llvm/lib/Transforms/Vectorize/LoopVectorize.cpp') diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp index 3f16b03055a9..e62d57e6920b 100644 --- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp +++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp @@ -5696,7 +5696,7 @@ void LoopVectorizationCostModel::setCostBasedWideningDecision(ElementCount VF) { Instruction *I = Worklist.pop_back_val(); for (auto &Op : I->operands()) if (auto *InstOp = dyn_cast(Op)) - if ((InstOp->getParent() == I->getParent()) && !isa(InstOp) && + if (TheLoop->contains(InstOp) && !isa(InstOp) && AddrDefs.insert(InstOp).second) Worklist.push_back(InstOp); } -- cgit v1.2.3