[PATCH] D38765: Don't replace constants with constants in GVN
Davide Italiano via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 10 21:22:14 PDT 2017
This revision was automatically updated to reflect the committed changes.
Closed by commit rL315429: [GVN] Don't replace constants with constants. (authored by davide).
Changed prior to commit:
https://reviews.llvm.org/D38765?vs=118535&id=118536#toc
Repository:
rL LLVM
https://reviews.llvm.org/D38765
Files:
llvm/trunk/lib/Transforms/Scalar/GVN.cpp
llvm/trunk/test/Transforms/GVN/pr34908.ll
Index: llvm/trunk/test/Transforms/GVN/pr34908.ll
===================================================================
--- llvm/trunk/test/Transforms/GVN/pr34908.ll
+++ llvm/trunk/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)
Index: llvm/trunk/lib/Transforms/Scalar/GVN.cpp
===================================================================
--- llvm/trunk/lib/Transforms/Scalar/GVN.cpp
+++ llvm/trunk/lib/Transforms/Scalar/GVN.cpp
@@ -1362,6 +1362,11 @@
}
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());
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D38765.118536.patch
Type: text/x-patch
Size: 1164 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171011/4f31395d/attachment.bin>
More information about the llvm-commits
mailing list