OSDN Git Service

Fix PR/33305. caused by trying to simplify expressions in phi of ops that should...
authorDaniel Berlin <dberlin@dberlin.org>
Sat, 2 Sep 2017 02:18:44 +0000 (02:18 +0000)
committerDaniel Berlin <dberlin@dberlin.org>
Sat, 2 Sep 2017 02:18:44 +0000 (02:18 +0000)
commit026a351310bc0f3fab2594070e7150f47d207691
tree2287dc423dc5cc4fe2a480932798ead0479d039f
parent5263738d53262fcf65a9c9de690a458db4f7cbb3
Fix PR/33305. caused by trying to simplify expressions in phi of ops that should have no leaders.

Summary:
After a discussion with Rekka, i believe this (or a small variant)
should fix the remaining phi-of-ops problems.

Rekka's algorithm for completeness relies on looking up expressions
that should have no leader, and expecting it to fail (IE looking up
expressions that can't exist in a predecessor, and expecting it to
find nothing).

Unfortunately, sometimes these expressions can be simplified to
constants, but we need the lookup to fail anyway.  Additionally, our
simplifier outsmarts this by taking these "not quite right"
expressions, and simplifying them into other expressions or walking
through phis, etc.  In the past, we've sometimes been able to find
leaders for these expressions, incorrectly.

This change causes us to not to try to phi of ops such expressions.
We determine safety by seeing if they depend on a phi node in our
block.

This is not perfect, we can do a bit better, but this should be a
"correctness start" that we can then improve.  It also requires a
bunch of caching that i'll eventually like to eliminate.

The right solution, longer term, to the simplifier issues, is to make
the query interface for the instruction simplifier/constant folder
have the flags we need, so that we can keep most things going, but
turn off the possibly-invalid parts (threading through phis, etc).
This is an issue in another wrong code bug as well.

Reviewers: davide, mcrosier

Subscribers: sanjoy, llvm-commits

Differential Revision: https://reviews.llvm.org/D37175

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@312401 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/Scalar/NewGVN.cpp
test/Transforms/NewGVN/completeness.ll
test/Transforms/NewGVN/pr33185.ll
test/Transforms/NewGVN/pr33305.ll [new file with mode: 0644]
test/Transforms/NewGVN/pr33432.ll [new file with mode: 0644]
test/Transforms/NewGVN/pr33461.ll