On Tue, 23 Jul 2019, Kewen.Lin wrote: > on 2019/7/22 ÏÂÎç3:18, Richard Biener wrote: > > On Mon, 22 Jul 2019, Segher Boessenkool wrote: > > > >> Hi! > >> > >> (Maybe I am missing half of the discussion -- sorry if so). > >> > >> I think we should have a new iv for just the doloop (which can have the > >> same starting value and step and type as another iv). > >> > >> Has this been considered? > > > > I was also suggesting this (maybe with too many words ;)). If > > it's a doloop target add such IV (candidate!) which has zero > > use-cost for the increment and compare but a (target configurable) > > penalty for other uses. Invasiveness of this approach is probably > > that you need to distinguish this candidate by making it a new > > kind (or maybe we can just have a specia candidate number...). > > > > Hi Richard, > > Really appreciate your comments on this, very sorry not to go with this. > Since this patch is for TARGET_HAVE_COUNT_REG_DECR_P, I was thinking > it's fairly enough to reuse the existing IV cands and just zeroing doloop > use cost with them. I'm very happy to unify it. If you/Segher/Bin don't > have any concerns, I'd like to make it as one follow up item. > > One thing to double check is this dedicated IV will follow decrement > instead of increment align with doloop optimize? Then it looks to shape > the loop closing to doloop pattern, at least it's decrement. I think doloop support should be as "simple" as always adding a candidate starting from niter (-1?), step -1 marked as DOLOOP_IV (which is then used in costing, making uses in the IV update and the compare zero cost and uses in other places according to the target by using an appropriate hardreg for the fake RTL we create). IV costing and elimination should then choose the doloop IV if that's profitable. Richard.