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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|c                           |ipa
   Last reconfirmed|                            |2022-05-27
     Ever confirmed|0                           |1
           Keywords|                            |missed-optimization
                 CC|                            |hubicka at gcc dot gnu.org,
                   |                            |marxin at gcc dot gnu.org,
                   |                            |rguenth at gcc dot gnu.org
             Status|UNCONFIRMED                 |NEW

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
the dummy1/dummy2 optimizations could eventually be done by DCE if we knew that
'removeme' is only ever accessed from 'dummy1' / 'dummy2', in that case we
could consider the variable local and since there's no data dependence on it
we could elide it.

Don't we track that already in IPA?  I think local passes cannot rely on
IPA references?  We also need to consider

void foo (int *);
int dummy1()
{
  static int removeme = 0;
  static int *p = &removeme;
  foo (p);
  if (removeme)
  {
      return 0;
  }
  removeme = 1;
  return 0;
}

thus global CTORs (the above will see the init in dummy1(), but not sure
whether we can rely on that?)

Reply via email to