[PATCH] D37175: Fix PR/33305. caused by trying to simplify expressions in phi of ops that should have no leaders.

Daniel Berlin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 25 20:36:25 PDT 2017


dberlin created this revision.
Herald added a subscriber: sanjoy.

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, 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 them, incorrectly.

This change causes us to not use the simplifier on such
expressions. We determine safety by seeing if they depend on a phi
node dominated by our block.

This is not perfect, we can do 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 only thing i am not 100% positive on is whether it is safe to
apply constant folding. It looks like our constant folder will also
use computeknownbits to go walking through things, and i'm not
positive that is safe.

The right solution, longer term, 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).

My plan is to start with this patch, and see if anyone can find an
issue with constant folding.  If so, we'll give up and scale it back
till we can change the query interface for the simplifier and use that.


https://reviews.llvm.org/D37175

Files:
  lib/Transforms/Scalar/NewGVN.cpp
  test/Transforms/NewGVN/completeness.ll
  test/Transforms/NewGVN/pr33305.ll
  test/Transforms/NewGVN/pr33461.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D37175.112780.patch
Type: text/x-patch
Size: 30335 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170826/f44716fe/attachment.bin>


More information about the llvm-commits mailing list