[LICM] Use poison to replace unreachable values instead of undef [NFC]

This commit is contained in:
Nuno Lopes 2022-06-26 14:56:35 +01:00
parent 282059b44d
commit 6ef9a2ad01
4 changed files with 13 additions and 13 deletions

View File

@ -1606,7 +1606,7 @@ static bool sink(Instruction &I, LoopInfo *LI, DominatorTree *DT,
continue;
if (!DT->isReachableFromEntry(User->getParent())) {
U = UndefValue::get(I.getType());
U = PoisonValue::get(I.getType());
Changed = true;
continue;
}
@ -1619,7 +1619,7 @@ static bool sink(Instruction &I, LoopInfo *LI, DominatorTree *DT,
// unreachable.
BasicBlock *BB = PN->getIncomingBlock(U);
if (!DT->isReachableFromEntry(BB)) {
U = UndefValue::get(I.getType());
U = PoisonValue::get(I.getType());
Changed = true;
continue;
}

View File

@ -1,20 +1,20 @@
; RUN: opt -licm -S < %s | FileCheck %s
define void @f() {
define void @f(i1 %c) {
; CHECK-LABEL: @f(
entry:
br label %bb0
bb0:
%tobool7 = icmp eq i1 undef, undef
%tobool7 = icmp eq i1 0, 1
br label %bb1
bb1:
br i1 undef, label %bb0, label %bb0
br i1 %c, label %bb0, label %bb0
unreachable:
; CHECK-LABEL: unreachable:
; CHECK: br i1 undef, label %unreachable, label %unreachable
; CHECK: br i1 poison, label %unreachable, label %unreachable
br i1 %tobool7, label %unreachable, label %unreachable
bb3:

View File

@ -9,11 +9,11 @@ lbl.loopexit: ; No predecessors!
br label %lbl
lbl: ; preds = %lbl.loopexit, %entry
%phi = phi i32 [ %conv, %lbl.loopexit ], [ undef, %entry ]
; CHECK: phi i32 [ undef, {{.*}} ], [ undef
%phi = phi i32 [ %conv, %lbl.loopexit ], [ poison, %entry ]
; CHECK: phi i32 [ poison, {{.*}} ], [ poison
br label %if.then.5
if.then.5: ; preds = %if.then.5, %lbl
%conv = zext i1 undef to i32
%conv = zext i1 0 to i32
br label %if.then.5
}

View File

@ -5,16 +5,16 @@ target triple = "x86_64-unknown-linux-gnu"
; CHECK-LABEL: @f1
; CHECK-LABEL: bci_524:
; CHECK: add i32 undef, undef
define void @f1(i32 %v) {
; CHECK: add i32 poison, poison
define void @f1(i32 %v, i1 %c) {
not_zero.lr.ph:
br label %not_zero
not_zero:
br i1 undef, label %bci_748 , label %bci_314
br i1 %c, label %bci_748 , label %bci_314
bci_314:
%0 = select i1 undef, i32 undef, i32 undef
%0 = select i1 poison, i32 poison, i32 poison
br label %not_zero
bci_524: ; No predecessors!