[PATCH] D110620: [SCEV] Infer ranges for SCC consisting of cycled Phis

Philip Reames via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 30 09:33:33 PST 2021


reames added a comment.

Ok, sorry for taking so long to reply to this.  Something had been bugging me, and I hadn't quite taken the time to figure out what.  I finally did.

I think this solution is majorly overkill, and adds an amount of complexity which is not justified.  Let me walk through an alternate approach; I'm curious what you think.

The basic problem we have is a loop nest where the inner loop has an unknown trip count, and an addrec IV.  This inner loop is wrapped in an outer loop which uses the increment of the inner IV as the backedge value of the outer IV.  It's worth highlighting that if the inner loop had a computable trip count, the outer loops IV would likely also become an addrec.  We can totally form the expression for the step of the outer loop, but since it's not loop invariant in the outer loop, we don't have an addrec.

As a brief aside, I've long wondered whether we should allow addrec's with loop varying step.  If we did, we'd have a clean model for the outer IV.  I'm not proposing we do that now, just mentioning it.

However, I think we can and should pattern match this "almost an addrec" pattern in the range check logic.  Looking at a SCEVUnknown phi, checking to see if it matches this pattern (loop header, backedge is addrec with start value function of self, check!) is pretty straight forward.  Much much simpler than the SCC matching at least.

Unless you have a motivating case which is not a nested loop, I think we should do this approach instead.


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

https://reviews.llvm.org/D110620



More information about the llvm-commits mailing list