[PATCH] D49384: [IPSCCP] Do not zap return if the return value is overdefined at any call site.

Eli Friedman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 16 17:20:02 PDT 2018


efriedma added a comment.

Thought about it a bit more, came up with an alternative fix: https://reviews.llvm.org/D49408.  It's a bit more aggressive, and avoids the weirdness of calling markForcedConstant on an arbitrary value.

> Just marking undef conditions as overdefined after a round of Solve()?

I'm not completely sure.

The academic algorithm for SCCP has three lattice states.  The first state, there's no viable path to execute the instruction producing the value ("undef").  The second state, all viable paths produce the same value ("constant").  The third state, there are multiple possible values ("overdefined").

The LLVM version essentially tries to incorporate a fourth state: the instruction executes, but the result is the LLVM value "undef", so we can choose a constant to replace it later.  But the implementation is awkward because the lattice doesn't represent the difference between this state and the "undef" state, and we try to fix it up later in ResolveUndefsIn.  I think we should fix the lattice to represent this explicitly: "undef" should be split into "dead" and "indeterminate".  (This would probably allow SCCP to find more constants, because we wouldn't need to ResolvedUndefsIn on dead instructions.)  If we do that, though, I guess we have to continue using something like ResolvedUndefsIn; but at least it would be more clear why it's necessary.


https://reviews.llvm.org/D49384





More information about the llvm-commits mailing list