[llvm-branch-commits] [llvm] release/23.x: [VPlan] Split legalizeAndOptimizeIVs in 2 phases. (#217765) (PR #233472)

Nikita Popov via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Mon Oct 19 09:02:02 PDT 2026


nikic wrote:

For this test case:
```llvm
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32"
target triple = "aarch64-unknown-linux-gnu"

define float @test(i64 %0) #0 {
.loopexit36:
  br label %1

1:                                                ; preds = %1, %.loopexit36
  %2 = phi ptr [ %7, %1 ], [ null, %.loopexit36 ]
  %3 = phi float [ %8, %1 ], [ 0.000000e+00, %.loopexit36 ]
  %4 = phi i64 [ %5, %1 ], [ 0, %.loopexit36 ]
  %5 = add i64 %4, 1
  %6 = icmp ne ptr %2, null
  tail call void @llvm.assume(i1 %6)
  %7 = getelementptr i8, ptr %2, i64 1
  %8 = fadd float %3, 0.000000e+00
  %9 = icmp eq i64 %4, %0
  br i1 %9, label %10, label %1

10:                                               ; preds = %1
  ret float %8
}

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write)
declare void @llvm.assume(i1 noundef) #1

attributes #0 = { "target-cpu"="gb10" }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write) }
```
This fixes the following assertion failure:
```
Found phi-like recipe after non-phi recipe: WIDEN-REDUCTION-PHI ir<%26> = phi (fadd) ir<%bc.merge.rdx>, ir<%31>
after
EMIT vp<%next.gep> = ptradd ir<%bc.resume.val>, vp<%index>
opt: /home/npopov/repos/llvm-project-rebase/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:6029: DenseMap<const SCEV *, Value *> llvm::LoopVectorizationPlanner::executePlan(ElementCount, unsigned int, VPlan &, InnerLoopVectorizer &, DominatorTree *, EpilogueVectorizationKind): Assertion `verifyVPlanIsValid(BestVPlan) && "final VPlan is invalid"' failed.
```
Reported at https://github.com/rust-lang/rust/issues/164584.

@fhahn If I understand correctly the commit was not originally intended to fix any assertion failures, so I want to double check that backporting this one is right and it's not just accidentally hiding the issue.

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


More information about the llvm-branch-commits mailing list