This is an archive of the discontinued LLVM Phabricator instance.

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

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

Details

Summary

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
values.

Diff Detail

Repository
rL LLVM

Event Timeline

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

LGTM

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?

Hi,

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
https://bugs.llvm.org/show_bug.cgi?id=39673
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