[VPlan] Mov licm to end of VPlan optimizations.
This moves licm after expanding replicate regions. This fixes a crash when trying to hoist a predicated VPReplicateRecipes which later get expanded to replicate regions. Hoisting replicate regions out was not intended (see the discussion and at the review and comment on shallow traversal in licm()). Fixes https://github.com/llvm/llvm-project/issues/109510.
This commit is contained in:
@@ -1158,7 +1158,6 @@ void VPlanTransforms::optimize(VPlan &Plan) {
|
||||
removeRedundantInductionCasts(Plan);
|
||||
|
||||
simplifyRecipes(Plan);
|
||||
licm(Plan);
|
||||
legalizeAndOptimizeInductions(Plan);
|
||||
removeDeadRecipes(Plan);
|
||||
|
||||
@@ -1166,6 +1165,7 @@ void VPlanTransforms::optimize(VPlan &Plan) {
|
||||
|
||||
removeRedundantExpandSCEVRecipes(Plan);
|
||||
mergeBlocksIntoPredecessors(Plan);
|
||||
licm(Plan);
|
||||
}
|
||||
|
||||
// Add a VPActiveLaneMaskPHIRecipe and related recipes to \p Plan and replace
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
; RUN: opt -p loop-vectorize -force-vector-width=4 -S %s | FileCheck %s
|
||||
|
||||
target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128-Fn32"
|
||||
target triple = "arm64-apple-macosx14.0.0"
|
||||
|
||||
; Test for https://github.com/llvm/llvm-project/issues/109510.
|
||||
define i32 @test_invariant_replicate_region(i32 %x, i1 %c) {
|
||||
entry:
|
||||
br label %loop.header
|
||||
|
||||
loop.header:
|
||||
%iv = phi i32 [ 0, %entry ], [ %iv.next, %loop.latch ]
|
||||
br i1 %c, label %then, label %loop.latch
|
||||
|
||||
then:
|
||||
%rem.1 = urem i32 10, %x
|
||||
br label %loop.latch
|
||||
|
||||
loop.latch:
|
||||
%res = phi i32 [ 0, %loop.header ], [ %rem.1, %then ]
|
||||
%iv.next = add i32 %iv, 1
|
||||
%ec = icmp eq i32 %iv, 99
|
||||
br i1 %ec, label %exit, label %loop.header
|
||||
|
||||
exit:
|
||||
ret i32 %res
|
||||
}
|
||||
Reference in New Issue
Block a user