Page MenuHomePhabricator

[SCEV] Teach computeSCEVAtScope benefit from one-input Phi. PR39673

Authored by mkazantsev on Feb 12 2019, 3:57 AM.



SCEV does not propagate arguments through one-input Phis for sake of LCSSA
form preservation. So whenever computeSCEVAtScope is asked about such Phi,
it will not go ahead and try to analyze its input. However it is possible that when
an this input leaves the loop through LCSSA Phi, it is a provable constant.

This patch teaches computeSCEVAtScope about this case. We can generalize it
later, but so far we can only replace LCSSA Phis with their constant loop-exiting

Diff Detail


Event Timeline

mkazantsev created this revision.Feb 12 2019, 3:57 AM


I'm fine with this landing, since the patch is an obvious improvement. However, I have to admit I don't understand the interaction between LCSSA and SCEV here. Why does SCEV need to care that a phi might be a LCSSA phi? They seem orthogonal. Maybe *some particular caller* might need to care, but that seems like a different issue?


Should we/someone push this?

I don't know, but I haven't seen much/any activity from mkazantsev in llvm
for some time now, so I'm not sure if someone else should commit this change?

It does seem to fix the regression described in
but myself I've no idea if the change makes sense or not.

This revision was not accepted when it landed; it landed in state Needs Review.Jun 12 2019, 10:20 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptJun 12 2019, 10:20 AM