Skip to content
This repository was archived by the owner on Feb 5, 2019. It is now read-only.

Commit 83b72ce

Browse files
dccialexcrichton
authored andcommitted
[GVN] Don't replace constants with constants.
This fixes PR34908. Patch by Alex Crichton! Differential Revision: https://reviews.llvm.org/D38765 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@315429 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 76fce77 commit 83b72ce

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

lib/Transforms/Scalar/GVN.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1747,6 +1747,11 @@ bool GVN::processAssumeIntrinsic(IntrinsicInst *IntrinsicI) {
17471747
}
17481748
markInstructionForDeletion(IntrinsicI);
17491749
return false;
1750+
} else if (isa<Constant>(V)) {
1751+
// If it's not false, and constant, it must evaluate to true. This means our
1752+
// assume is assume(true), and thus, pointless, and we don't want to do
1753+
// anything more here.
1754+
return false;
17501755
}
17511756

17521757
Constant *True = ConstantInt::getTrue(V->getContext());

test/Transforms/GVN/pr34908.ll

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2+
; RUN: opt < %s -gvn -S | FileCheck %s
3+
4+
define i1 @foo() {
5+
; CHECK-LABEL: @foo(
6+
; CHECK-NEXT: call void @llvm.assume(i1 undef)
7+
; CHECK-NEXT: ret i1 undef
8+
;
9+
call void @llvm.assume(i1 undef)
10+
ret i1 undef
11+
}
12+
13+
declare void @llvm.assume(i1)

0 commit comments

Comments
 (0)