This is an archive of the discontinued LLVM Phabricator instance.

[IndVarSimplify] Never sinking if none operand is used in or after loop exit block
Needs RevisionPublic

Authored by xjtuhu on Mar 22 2021, 11:10 PM.

Details

Summary

IndVarSimplify::sinkUnusedInvariants would sink a instruction from a loop's preheader block to exit block to reduce register pressure. But the optimization is not conservative, it could increase register pressure conversely if none operand is used in or after loop exit block, because sinking could extend operands' liveness range hence increase register pressure.

Diff Detail

Event Timeline

xjtuhu created this revision.Mar 22 2021, 11:10 PM
xjtuhu requested review of this revision.Mar 22 2021, 11:10 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 22 2021, 11:10 PM
lebedev.ri retitled this revision from Never sinking if none operand is used in or after loop exit block to [IndVarSimplify] Never sinking if none operand is used in or after loop exit block.Mar 23 2021, 12:39 AM

This looks pretty ad-hoc to me.
I believe we consider this to be a canonicalization transform that will be undone by other passes if profitable.

reames requested changes to this revision.Mar 23 2021, 9:52 AM

Change rejected. As Roman mentions, this is more of a canonicalization than an optimization. If you want to do actual scheduling, please use the MI layer.

p.s. The wording "If none operand is used" does not parse for me. I think I get the intent of the change, but I'd suggest rewording any future discussion of this.

This revision now requires changes to proceed.Mar 23 2021, 9:52 AM

OK, I see. Thanks for giving the advice!