mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 18:54:02 +01:00
a4f9bca98e
Turns out simplifyLoopIVs sometimes returns a non-dead instruction in it's DeadInsts out param. I had done a bit of NFC cleanup which was only NFC if simplifyLoopIVs obeyed it's documentation. I'm simplfy dropping that part of the change. Commit message from try 3: Recommitting after fixing a bug found post commit. Amusingly, try 1 had been correct, and by reverting to incorporate last minute review feedback, I introduce the bug. Oops. :) Original commit message: The problem was that recursively deleting an instruction can delete instructions beyond the current iterator (via a dead phi), thus invalidating iteration. Test case added in LoopUnroll/dce.ll to cover this case. LoopUnroll does a limited DCE pass after unrolling, but if you have a chain of dead instructions, it only deletes the last one. Improve the code to recursively delete all trivially dead instructions. Differential Revision: https://reviews.llvm.org/D102511
61 lines
1.5 KiB
LLVM
61 lines
1.5 KiB
LLVM
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
|
|
; RUN: opt -loop-unroll -S < %s | FileCheck %s
|
|
|
|
; Can't recursively delete %c.addr.07 without deleting %conv1
|
|
; and thus invalidating iteration.
|
|
define void @PR50368(i32 %c, i64 %x) {
|
|
; CHECK-LABEL: @PR50368(
|
|
; CHECK-NEXT: entry:
|
|
; CHECK-NEXT: br label [[LOOP_PEEL_BEGIN:%.*]]
|
|
; CHECK: loop.peel.begin:
|
|
; CHECK-NEXT: br label [[LOOP_PEEL:%.*]]
|
|
; CHECK: loop.peel:
|
|
; CHECK-NEXT: br i1 false, label [[EXIT:%.*]], label [[LOOP_PEEL_NEXT:%.*]]
|
|
; CHECK: loop.peel.next:
|
|
; CHECK-NEXT: br label [[LOOP_PEEL_NEXT1:%.*]]
|
|
; CHECK: loop.peel.next1:
|
|
; CHECK-NEXT: br label [[ENTRY_PEEL_NEWPH:%.*]]
|
|
; CHECK: entry.peel.newph:
|
|
; CHECK-NEXT: br label [[LOOP:%.*]]
|
|
; CHECK: loop:
|
|
; CHECK-NEXT: br i1 false, label [[EXIT_LOOPEXIT:%.*]], label [[LOOP]], !llvm.loop [[LOOP0:![0-9]+]]
|
|
; CHECK: exit.loopexit:
|
|
; CHECK-NEXT: br label [[EXIT]]
|
|
; CHECK: exit:
|
|
; CHECK-NEXT: ret void
|
|
;
|
|
entry:
|
|
br label %loop
|
|
|
|
loop:
|
|
%0 = phi i64 [ 0, %loop ], [ %x, %entry ]
|
|
%c.addr.07 = phi i32 [ %conv1, %loop ], [ %c, %entry ]
|
|
%conv1 = trunc i64 undef to i32
|
|
br i1 false, label %exit, label %loop
|
|
|
|
exit:
|
|
ret void
|
|
}
|
|
|
|
|
|
define void @dead_chain(i64 %a) {
|
|
; CHECK-LABEL: @dead_chain(
|
|
; CHECK-NEXT: entry:
|
|
; CHECK-NEXT: br label [[LOOP:%.*]]
|
|
; CHECK: loop:
|
|
; CHECK-NEXT: ret void
|
|
;
|
|
entry:
|
|
br label %loop
|
|
|
|
loop:
|
|
%conv1 = trunc i64 %a to i32
|
|
%and = and i32 %conv1, 15
|
|
%shl = shl i32 %and, 15
|
|
br i1 true, label %exit, label %loop
|
|
|
|
exit:
|
|
ret void
|
|
}
|
|
|