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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jamborm at gcc dot gnu.org
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2024-04-26
           Priority|P3                          |P2
            Version|unknown                     |14.0
   Target Milestone|---                         |12.4
             Status|UNCONFIRMED                 |NEW

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
int main ()
{
  <bb 2> [local count: 1073741824]:
  c.b = 0;
  return 0;

}


Confirmed.  It seems we are confused during inlining and substitute
'c' for 'f' because both are readonly.  But the write to f is to an
automatic var and thus not readonly memory.

Note the write to f is introduced by SRA so I think it's SRAs fault:

void e (const struct a f)
 {
+  const int f$b;
   int _1;
   int iftmp.0_4;

   <bb 2> :
-  _1 = f.b;
+  f$b_3 = f.b;
+  _1 = f$b_3;
   if (_1 != 0)
     goto <bb 3>; [INV]
   else
     goto <bb 4>; [INV]

   <bb 3> :
-  iftmp.0_4 = f.b;
+  iftmp.0_4 = f$b_3;

   <bb 4> :
+  f.b = f$b_3;
   d (f);

The store is broken.  I think a readonly aggegate never needs to be
re-materialized as it cannot be changed (do we track possible writes?)

Reply via email to