[PATCH] D129293: [IndVars] Simplify instructions after replacing header phi with preheader value
Nikita Popov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 14 02:27:42 PDT 2022
nikic added a comment.
@mstorsjo Thanks for the report! Here's a reduced test case:
define i64 @test(i64 %arg) {
entry:
br label %loop1
loop1:
%iv1 = phi i64 [ 0, %entry ], [ 1, %loop1.latch ]
br label %loop2
loop2:
%iv2 = phi i64 [ 0, %loop1 ], [ 1, %loop2 ]
%res = add nuw nsw i64 %iv1, %iv2
br i1 true, label %loop2, label %loop1.latch
loop1.latch:
%res.lcssa = phi i64 [ %res, %loop2 ]
br i1 false, label %loop1, label %exit
exit:
%res.lcssa2 = phi i64 [ %res.lcssa, %loop1.latch ]
ret i64 %res.lcssa2
}
This gets reduced to:
define i64 @t(i64 %arg) {
entry:
br label %loop1
loop1: ; preds = %loop1.latch, %entry
br label %loop2
loop2: ; preds = %loop2, %loop1
%iv2 = phi i64 [ 0, %loop1 ], [ 1, %loop2 ]
br i1 true, label %loop2, label %loop1.latch
loop1.latch: ; preds = %loop2
br i1 false, label %loop1, label %exit
exit: ; preds = %loop1.latch
%res.lcssa2 = phi i64 [ %iv2, %loop1.latch ]
ret i64 %res.lcssa2
}
We need to make sure that we don't fold away any LCSSA phi nodes of inner loops.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D129293/new/
https://reviews.llvm.org/D129293
More information about the llvm-commits
mailing list