[Bug ipa/84658] [7/8 Regression] -O3 -fmerge-all-constants causes incorrect for-each loop generation.

jakub at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Fri Mar 2 12:21:00 GMT 2018


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

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Seems the inliner immediately undoes what ICF did and both get inlined into
main as well.
The aD.2373 array becomes an alias of aD.2363.
And the real bug is introduced in ccp2:
Folding predicate __for_begin_5 == &MEM[(void *)&a + 64B] to 0
on previously:
  intD.9 bD.2396;
  const intD.9 * __for_beginD.2397;
  static const intD.9 aD.2363[16] = {0, 1, 2, 3, 4, 5, 8, 15, 16, 17, 512,
1020, 1021, 1022, 1023, 1024};
  intD.9 bD.2394;
  const intD.9 * __for_beginD.2395;
  static const intD.9 aD.2373[16];

  <bb 2> [local count: 63136019]:
  printf ("foo ");

  <bb 3> [local count: 1073741820]:
  # __for_begin_8 = PHI <&aD.2363(2), __for_begin_10(4)>
  if (__for_begin_8 == &MEM[(voidD.46 *)&aD.2363 + 64B])
    goto <bb 5>; [5.88%]
  else
    goto <bb 4>; [94.12%]

  <bb 4> [local count: 1010605800]:
  b_9 = *__for_begin_8;
  printf ("%d, ", b_9);
  __for_begin_10 = __for_begin_8 + 4;
  goto <bb 3>; [100.00%]

  <bb 5> [local count: 63136019]:
  printf ("end\nbar ");

  <bb 6> [local count: 1073741825]:
  # __for_begin_5 = PHI <&aD.2373(5), __for_begin_7(7)>
  if (__for_begin_5 == &MEM[(voidD.46 *)&aD.2373 + 64B])
    goto <bb 8>; [5.88%]
  else
    goto <bb 7>; [94.12%]

  <bb 7> [local count: 1010605805]:
  b_6 = *__for_begin_5;
  printf ("%d, ", b_6);
  __for_begin_7 = __for_begin_5 + 4;
  goto <bb 6>; [100.00%]

  <bb 8> [local count: 63136019]:
  __builtin_puts (&"end"[0]);


More information about the Gcc-bugs mailing list