This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Preliminary patch for PR23820 and PR24309


Hello,

> loop header copying is run after the first VRP pass, but DOM usually
> catches this.  Now in this case DOM needs enabling transformations.
> 
> Why do we run loop header copying so late?  If it doesn't cause
> problems if would run it as first optimization after inlining (which
> obviously fixes the problems you see, the first VRP pass removes
> the comparison).  The last place in the pass pipeline that still
> works is just before FRE.

in some cases, moving loop header copying earlier led to missed
optimizations.  Like e.g. in the following code, before loop header
copying:

i = 0;
while (1)
  {
    if (i >= n) break;

    if (i >= n)
      error ("access outside of array");
    a[i] = i;

    i++;
  }

the second check for i >= n will obviously be eliminated.  After loop
header copying,

i = 0;
if (0 < n)
  {
    while (1)
      {
        if (i >= n)
          error ("access outside of array");
        a[i] = i;

        i++;
        if (i >= n) break;
      }
  }

it is much harder to determine that the condition is redundant
(certainly we were not able to do that before VRP was introduced; I am
not sure whether VRP handles this case or not).  So we run loop
header copying only after some basic cleanups (especially DOM)
had chance to simplify such conditions.

Zdenek


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]