> On Fri, Jul 28, 2023 at 2:57 PM Jan Hubicka via Gcc-patches > <gcc-patches@gcc.gnu.org> wrote: > > > > Hi, > > This patch extends tree-ssa-loop-split to understand test of the form > > if (i==0) > > and > > if (i!=0) > > which triggers only during the first iteration. Naturally we should > > also be able to trigger last iteration or split into 3 cases if > > the test indeed can fire in the middle of the loop. > > > > Last iteration is bit trickier pattern matching so I want to do it > > incrementally, but I implemented easy case using value range that handled > > loops with constant iterations. > > > > The testcase gets misupdated profile, I will also fix that incrementally. > > > > Bootstrapped/regtested x86_64-linux, OK? > > OK, though I think we can handle more loops by simply conservatively peeling > one iteration at the beginning/end with such conditions and would be not > subject > to all other limitations the loop splitting pass has?
I was also thinking of extending loop peeling heuristics by this. Loop-ch already can handle case where the static test exits loop, so we could get this if I figure out how to merge the analysis. To handle last iteration (like in hmmer), we would need to extend loop peeling to support that. Even with that tree-ssa-loop-split has chance to be more informed and have better cost model. Let me see how many restrictions can be dropped it. Honza