[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 11:59:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84658
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org
--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Adjusted testcase for the testsuite:
// PR ipa/84658
// { dg-do run }
// { dg-options "-O3 -fmerge-all-constants" }
// { dg-output "foo 0, 1, 2, 3, 4, 5, 8, 15, 16, 17, 512, 1020, 1021, 1022,
1023, 1024, end.*" }
// { dg-output "bar 0, 1, 2, 3, 4, 5, 8, 15, 16, 17, 512, 1020, 1021, 1022,
1023, 1024, end" }
extern "C" int printf (const char *, ...);
void
foo ()
{
const int a[] = { 0, 1, 2, 3, 4, 5, 8, 15, 16, 17, 512, 1020, 1021, 1022,
1023, 1024 };
for (int b : a)
printf ("%d, ", b);
}
void
bar ()
{
const int a[] = { 0, 1, 2, 3, 4, 5, 8, 15, 16, 17, 512, 1020, 1021, 1022,
1023, 1024 };
for (int b : a)
printf ("%d, ", b);
}
int
main ()
{
printf ("foo ");
foo ();
printf ("end\nbar ");
bar ();
printf ("end\n");
}
More information about the Gcc-bugs
mailing list