[Bug tree-optimization/97053] [10/11 Regression] an O2, O3 codegen bug
jakub at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue Sep 15 09:53:39 GMT 2020
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97053
--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Better testcase that won't cease to test the bug even if FRE or some other pass
gets smarter and optimizes the a = "XXXXXXXX"; __builtin_memcpy (&a, "ABCD",
4);
into a = "ABCDXXXX":
struct S { short a; char b[9]; int c; char d; int e; };
__attribute__((noipa)) void
foo (struct S *x)
{
if (__builtin_strcmp (x->b, "ABCDXXXX") != 0)
__builtin_abort ();
}
__attribute__((noipa)) void
bar (char *x)
{
struct S b = {};
b.a = 5;
__builtin_memcpy (b.b, x, 8);
b.d = 'X';
b.e = 1;
foo (&b);
}
int
main ()
{
bar ("ABCDXXXX");
return 0;
}
(In reply to Eric Botcazou from comment #2)
> The statement generated by DSE
>
> MEM <char[12]> [(struct Data *)&data + 8B] = {};
>
> looks nonsensical and I guess store-merging is not prepared for it.
There is nothing non-sensical nor wrong on it, it is standard GIMPLE IL,
equivalent in behavior to __builtin_memset (&data + 8B, 0, 12);
More information about the Gcc-bugs
mailing list