On Tue, 30 May 2023, Richard Sandiford wrote: > Richard Biener <rguent...@suse.de> writes: > >> But how easy would it be to extend SCEV analysis, via a pattern match? > >> The evolution of the IV phi wrt the inner loop is still a normal SCEV. > > > > No, the IV isn't a normal SCEV, the final value is different. > > Which part of the IV though?
The relevant IV (for niter analysis) is the one used in the loop exit test and that currently isn't a SCEV. The IV used in the *_len operations isn't either (and that's not going to change, obviously). > Won't all executions of the latch edge > decrement the IV phi (and specifically the phi) by VF (and only VF)? But currently there's no decrement by invariant VF but only by MIN (VF, remain), that's what I suggested to address to make the loop exit condition analyzable (as said, in theory we can try pattern matching the analysis of the exit test in niter analysis). > So if we analyse the IV phi wrt the inner loop, the IV phi is simply > { initial, -, VF }. > > I agree "IV phi - step" isn't a SCEV, but that doesn't seem fatal. Right. Fatal is the non-SCEV in the exit test which makes most followup loop optimizations fail to consider the loop because the number of iterations cannot be determined. Richard.