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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |NEW
                 CC|                            |jakub at gcc dot gnu.org
           Assignee|rguenth at gcc dot gnu.org         |unassigned at gcc dot 
gnu.org

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
So

   <bb 2> [local count: 13270966]:
+  vect_cst__42 = { 0, 0, 0, 0 };
   c.0_1 = c;
   _100 = 5;
   _15 = _100 + 4;
@@ -202,10 +1035,7 @@
   ivtmp_72 = ivtmp_66 + 65535;
   e = 0;
   a[8] = 0;
-  a[7] = 0;
-  a[6] = 0;
-  a[5] = 0;
-  a[4] = 0;
+  MEM[(int *)&a + 16B] = vect_cst__42;
   a[3] = 0;
   b = 6;
   i.11_40 = i;

triggers it.  But then the actual issue is in store-merging which does

@@ -48,11 +56,10 @@
   a[5] = 1;
   _47 = *c.0_1;
   a[6] = _47;
-  a[4] = 1;
   e = 0;
   a[8] = 0;
   MEM[(int *)&a + 16B] = { 0, 0, 0, 0 };
-  a[3] = 0;
+  MEM[(int *)&a + 12B] = 4294967296;
   b = 6;
   i.11_40 = i;
   *i.11_40 = &g;

merging the dead a[4] = 1; across the clobbering MEM[(int *)&a + 16B] = { 0, 0,
0, 0 };

What triggers it in store-merging is the first non-constant RHS.  GIMPLE
testcase for easy debugging:

typedef int v4si __attribute__((vector_size(16)));
int a[10];
void __GIMPLE (ssa,startwith("store-merging"))
foo(int *p)
{
  int _2;
  __BB(2):
  _2 = *p_1(D);
  a[6] = _2;
  a[4] = 1;
  __MEM <v4si> ((int *)&a + _Literal (int *) 16) = _Literal (v4si) { 0, 0, 0, 0
};
  a[3] = 0;
  return;
}

commenting the a[6] = _2; line avoids the miscompile.

I'm not too familiar with store-merging so un-assigning myself.

Reply via email to