[Bug tree-optimization/94125] [9/10 Regression] wrong code at -O3 on x86_64-linux-gnu
rguenther at suse dot de
gcc-bugzilla@gcc.gnu.org
Mon Mar 16 07:38:07 GMT 2020
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94125
--- Comment #9 from rguenther at suse dot de <rguenther at suse dot de> ---
On Sun, 15 Mar 2020, amker at gcc dot gnu.org wrote:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94125
>
> --- Comment #7 from bin cheng <amker at gcc dot gnu.org> ---
> Patch at https://gcc.gnu.org/pipermail/gcc-patches/2020-March/542038.html
> It's a latent bug exposed by the mentioned alias analysis change, however:
>
>
> unsigned char b, f;
> short d[1][8][1], *g = &d[0][3][0];
>
> int
> main ()
> {
> int k[] = { 0, 0, 0, 4, 0, 0 };
> for (int c = 2; c >= 0; c--)
> {
> b = f;
> *g = k[c + 3];
> k[c + 1] = 0;
> }
> for (int i = 0; i < 8; i++)
> if (d[0][i][0] != 0)
> __builtin_abort ();
> return 0;
> }
>
> We can't tell no-alias info for pairs <f, *g> and <b, *g>. Is this expected or
> should be improved?
This is expected when g is not static [const] (we should discover it
as const) or when not using LTO (which should as well promote the
variable to const short *). Adding a restrict qualifier to g should
also solve it.
More information about the Gcc-bugs
mailing list