summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorFlorian Hahn <florian.hahn@arm.com>2018-11-07 17:20:07 +0000
committerFlorian Hahn <florian.hahn@arm.com>2018-11-07 17:20:07 +0000
commitac86038b407514cc1a93b05d0a4b375c49298a0b (patch)
tree57f37cc7700edfa77a37c858e874570dd076f49c /llvm/lib
parent5fbc72f5261ff381eae8494be462d48e7404d1b5 (diff)
downloadbcm5719-llvm-ac86038b407514cc1a93b05d0a4b375c49298a0b.tar.gz
bcm5719-llvm-ac86038b407514cc1a93b05d0a4b375c49298a0b.zip
[NewGVN] Make sure we do not add a user to itself.
If we simplify an instruction to itself, we do not need to add a user to itself. For congruence classes with a defining expression, we already use a similar logic. Fixes PR38259. Reviewers: davide, efriedma, mcrosier Reviewed By: davide Differential Revision: https://reviews.llvm.org/D51168 llvm-svn: 346335
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Transforms/Scalar/NewGVN.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/Scalar/NewGVN.cpp b/llvm/lib/Transforms/Scalar/NewGVN.cpp
index cd57ebd0c6f..9803bcb485d 100644
--- a/llvm/lib/Transforms/Scalar/NewGVN.cpp
+++ b/llvm/lib/Transforms/Scalar/NewGVN.cpp
@@ -1086,9 +1086,13 @@ const Expression *NewGVN::checkSimplificationResults(Expression *E,
CongruenceClass *CC = ValueToClass.lookup(V);
if (CC) {
if (CC->getLeader() && CC->getLeader() != I) {
- // Don't add temporary instructions to the user lists.
- if (!AllTempInstructions.count(I))
- addAdditionalUsers(V, I);
+ // If we simplified to something else, we need to communicate
+ // that we're users of the value we simplified to.
+ if (I != V) {
+ // Don't add temporary instructions to the user lists.
+ if (!AllTempInstructions.count(I))
+ addAdditionalUsers(V, I);
+ }
return createVariableOrConstant(CC->getLeader());
}
if (CC->getDefiningExpr()) {
OpenPOWER on IntegriCloud