Skip to content

Commit 974e5c8

Browse files
author
Jun Bum Lim
committed
[LICM] Fix PR35342
Summary: This change fix PR35342 by replacing only the current use with undef in unreachable blocks. Reviewers: efriedma, mcrosier, igor-laevsky Reviewed By: efriedma Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D40184 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@318551 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent ec6f9b0 commit 974e5c8

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

lib/Transforms/Scalar/LICM.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -906,7 +906,7 @@ static bool sink(Instruction &I, LoopInfo *LI, DominatorTree *DT,
906906
continue;
907907

908908
if (!DT->isReachableFromEntry(User->getParent())) {
909-
User->replaceUsesOfWith(&I, UndefValue::get(I.getType()));
909+
U = UndefValue::get(I.getType());
910910
continue;
911911
}
912912

test/Transforms/LICM/pr35342.ll

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
; RUN: opt -licm -S < %s | FileCheck %s
2+
3+
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128-ni:1"
4+
target triple = "x86_64-unknown-linux-gnu"
5+
6+
; CHECK-LABEL: @f1
7+
; CHECK-LABEL: bci_524:
8+
; CHECK: add i32 undef, undef
9+
define void @f1(i32 %v) {
10+
not_zero.lr.ph:
11+
br label %not_zero
12+
13+
not_zero:
14+
br i1 undef, label %bci_748 , label %bci_314
15+
16+
bci_314:
17+
%0 = select i1 undef, i32 undef, i32 undef
18+
br label %not_zero
19+
20+
bci_524: ; No predecessors!
21+
%add = add i32 %0, %0
22+
br label %bci_748
23+
24+
bci_748:
25+
ret void
26+
}

0 commit comments

Comments
 (0)