[llvm] [VPlan] Also expand integer SCEVAddExpr in expandSCEVExpr. (PR #200925)

Ramkumar Ramachandra via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 3 12:54:42 PDT 2026


================
@@ -910,12 +911,13 @@ VPValue *VPSCEVExpander::tryToReuseIRValue(const SCEV *S) {
   VPlan &Plan = Builder.getPlan();
   BasicBlock *PH = cast<VPIRBasicBlock>(Plan.getEntry())->getIRBasicBlock();
   for (Value *V : SE.getSCEVValues(S)) {
-    // Only reuse instructions in the plan's entry block, as instructions in
-    // sibling branches may not dominate the entry block.
+    // Only reuse instructions in the plan's entry block, or, when a
+    // DominatorTree is available, any instruction that dominates it.
+    // Instructions in sibling branches may not dominate the entry block.
     auto *I = dyn_cast<Instruction>(V);
     if (!I)
       return Plan.getOrAddLiveIn(V);
-    if (I->getParent() != PH)
+    if (DT ? !DT->dominates(I->getParent(), PH) : I->getParent() != PH)
----------------
artagnon wrote:

Hm, I wonder if DT needs to be optional, or if we can just pass a reference in all callsites? Where is the possibly-null-arg callsite?

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


More information about the llvm-commits mailing list