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

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
Testcase that did not regress:

struct S { int i; };

void foo (int *);

void bar (char *p)
{
  foo (&((struct S *)(p + 1))->i);
  foo ((int *)(p + 1));
}

Testcase that did regress (use -fgimple):

struct S { int i; };

void foo (int *);

void __GIMPLE (ssa)
bar (char * p)
{
  int * D_1997;
  int * _2;
  char * _3;

  __BB(2):
  _2 = &__MEM <struct S> ((struct S *)p_5(D) + _Literal (struct S *) 1).i;
  foo (_2);
  _3 = &__MEM <int> ((struct S *)p_5(D) + _Literal (struct S *)1);
  foo (_3);
  return;
}

it regressed because forwprop now rewrites one of the &MEMs:

--- t.c.033t.ccp1       2022-01-21 14:12:01.392883591 +0100
+++ t.c.034t.forwprop1  2022-01-21 14:12:01.392883591 +0100
@@ -10,7 +10,7 @@
   <bb 2> :
   _2_6 = &MEM[(struct S *)p_5(D) + 1B].i;
   foo (_2_6);
-  _3_9 = &MEM[(struct S *)p_5(D) + 1B];
+  _3_9 = p_5(D) + 1;
   foo (_3_9);
   return;

Reply via email to