https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117875

--- Comment #10 from rguenther at suse dot de <rguenther at suse dot de> ---
On Thu, 5 Dec 2024, hubicka at ucw dot cz wrote:

> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117875
> 
> --- Comment #9 from Jan Hubicka <hubicka at ucw dot cz> ---
> > > But maybe I'm missing something?
> > 
> > I guess the issue is that with
> > 
> > # k_24 = PHI <1(13), k_29(16)>
> > 
> > to easily see this we'd have to compute the range of
> > (unsigned int) M_9(D) - 1 and the range of (unsigned int) M_9(D) - 
> > (unsigned)
> > k_29 and then see those are the same singleton.  I don't think we can
> > arrive here when using the range of k_24 itself, so maybe I'm asking too
> > much of VRP here.
> 
> Yes, I don't see how ranger can figure out easily the singleton range,
> since final value of the iteration is variable.
> Last year I looked into it and I kind of remember implementing special
> matching code, but can not find the patch anymore. The code checking
> loop1->any_estimate can be generalized to check for estimate of one of
> the loop and adjust the other accordingly.
> 
> It is scev_cprop pass that does replace the use of IV value use out of
> loops by its bound. As in:
> #include <stdio.h>
> int test(int n)
> {
>         int i;
>         if (n < 0)
>                 return -1;
>         for (i = 0; i < n; i++)
>                 printf ("%i\n",i);
>         return i;
> }
> 
> Maybe we want to be able to run it on a specific loop and run it on
> loop1 between split finishes updating IL and before profile update?

That can be done already, I refactored the code to be run on a loop
a while back.  Just call final_value_replacement_loop (loop),
special casing it to a single PHI might be possible as well, of course.

Reply via email to