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.
This change slipped through the cracks.