[PATCH] D61314: [SCCP] Remove forcedconstant, go to overdefined instead

Eli Friedman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 17 12:11:44 PST 2020


efriedma added a comment.

I was thinking about this a bit more, and I'm not sure this is enough to allow value ranges to work correctly around undef.

The problem essentially boils down to this: what happens when an instruction that might return undef is marked "constantrange"?  If an instruction is marked "constant", it doesn't really matter if it really returns "constant or undef": SCCP will RAUW the instruction away, so it can't produce undef after SCCP runs.  If it's a constantrange, though, we never RAUW the value, so the "undef" case never goes away.  And if it's undef, it could be outside the computed range, and we could drop necessary arithmetic/comparisons.  For example, suppose we compute a value X is in range 0-255, and then we "and X, 255".  It looks like we could drop the "and"... but we never actually eliminated the possibility that the value was undef.  So now we've transformed "and undef, 255" -> "undef", which is wrong.

This problem specifically comes up because we resolve undefs "late", I think: if we treated undef as an overdefined value at the point where we initially analyzed it, this case wouldn't come up.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61314/new/

https://reviews.llvm.org/D61314





More information about the llvm-commits mailing list