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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2018-10-08
                 CC|                            |rguenth at gcc dot gnu.org
            Version|unknown                     |8.2.1
     Ever confirmed|0                           |1

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
The issue at -O2 is that we only unroll loops if we estimate that to not grow
code-size.  For f2 the estimate "works" while for f1 it doesn't because of
the awkward IV structure PRE present us with:

Estimating sizes for loop 1
 BB: 3, after_exit: 0
  size:   1 __init_12 = prephitmp_8 + __init_19;
  size:   1 __first_13 = __first_18 + 4;
  size:   1 ivtmp_10 = ivtmp_11 - 1;
   Induction variable computation will be folded away.
  size:   2 if (ivtmp_10 == 0)
   Exit condition will be eliminated in peeled copies.
   Exit condition will be eliminated in last copy.
   Constant conditional.
 BB: 4, after_exit: 1
  size:   1 pretmp_17 = MEM[(int *)__first_18 + 4B];
size: 6-3, last_iteration: 5-3
  Loop size: 6
  Estimated size after unrolling: 9
Not unrolling loop 1: size would grow.

  <bb 3> [local count: 955630224]:
  # __first_18 = PHI <&arr(2), __first_13(4)>
  # __init_19 = PHI <0(2), __init_12(4)>
  # prephitmp_8 = PHI <1(2), pretmp_17(4)>
  # ivtmp_11 = PHI <5(2), ivtmp_10(4)>
  __init_12 = prephitmp_8 + __init_19;
  __first_13 = __first_18 + 4;
  ivtmp_10 = ivtmp_11 - 1;
  if (ivtmp_10 == 0)
    goto <bb 5>; [12.36%]
  else
    goto <bb 4>; [87.64%]

  <bb 4> [local count: 837518623]:
  pretmp_17 = MEM[(int *)__first_18 + 4B];
  goto <bb 3>; [100.00%]

  <bb 5> [local count: 118111601]:

Reply via email to