diff options
| author | Davide Italiano <davide@freebsd.org> | 2017-10-11 04:21:51 +0000 |
|---|---|---|
| committer | Davide Italiano <davide@freebsd.org> | 2017-10-11 04:21:51 +0000 |
| commit | e2138fe41b8c98192669138d8f7595b541d08cc0 (patch) | |
| tree | 93e6b3aafb117f9a4108954ee00845bf97a4642c /llvm | |
| parent | 6a80e5dd3b30c26ab3b9403b9844162823527355 (diff) | |
| download | bcm5719-llvm-e2138fe41b8c98192669138d8f7595b541d08cc0.tar.gz bcm5719-llvm-e2138fe41b8c98192669138d8f7595b541d08cc0.zip | |
[GVN] Don't replace constants with constants.
This fixes PR34908. Patch by Alex Crichton!
Differential Revision: https://reviews.llvm.org/D38765
llvm-svn: 315429
Diffstat (limited to 'llvm')
| -rw-r--r-- | llvm/lib/Transforms/Scalar/GVN.cpp | 5 | ||||
| -rw-r--r-- | llvm/test/Transforms/GVN/pr34908.ll | 13 |
2 files changed, 18 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Scalar/GVN.cpp b/llvm/lib/Transforms/Scalar/GVN.cpp index 4e24d755c26..c3cc2375e3b 100644 --- a/llvm/lib/Transforms/Scalar/GVN.cpp +++ b/llvm/lib/Transforms/Scalar/GVN.cpp @@ -1362,6 +1362,11 @@ bool GVN::processAssumeIntrinsic(IntrinsicInst *IntrinsicI) { } markInstructionForDeletion(IntrinsicI); return false; + } else if (isa<Constant>(V)) { + // If it's not false, and constant, it must evaluate to true. This means our + // assume is assume(true), and thus, pointless, and we don't want to do + // anything more here. + return false; } Constant *True = ConstantInt::getTrue(V->getContext()); diff --git a/llvm/test/Transforms/GVN/pr34908.ll b/llvm/test/Transforms/GVN/pr34908.ll new file mode 100644 index 00000000000..c2b58ad34a6 --- /dev/null +++ b/llvm/test/Transforms/GVN/pr34908.ll @@ -0,0 +1,13 @@ +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py +; RUN: opt < %s -gvn -S | FileCheck %s + +define i1 @foo() { +; CHECK-LABEL: @foo( +; CHECK-NEXT: call void @llvm.assume(i1 undef) +; CHECK-NEXT: ret i1 undef +; + call void @llvm.assume(i1 undef) + ret i1 undef +} + +declare void @llvm.assume(i1) |

