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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Depends on|                            |64715

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Well, for N == 1 the early object-size pass computes 1 as size which means,
as it is supposed to be conservative, the closest surrounding subobject is
the higher-ranked subarray.  For N == a you get another conservative answer.
Early object-size can't put a constraint to it and then folding makes
a "mess" out of the address computation:

  <bb 2>:
  __builtin_memcpy (&MEM[(void *)&x2x3 + 2B], "abc", 4);
  return 0;

in ccp1.  To "fix" the simple case one could teach the objsz pass to lookup
the definition for a (and thus see the constant 1).  Or for example
integrate early objsz with CCP1 and apply things before applying the final
lattice.

I've repeatedly said the design of __builtin_object_size conflicts with the
desire to optimize -- one would need to preserve the original shape of the
access.
But only in some cases it seems.  There is an old bug about this, PR64715.


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64715
[Bug 64715] [5/6/7 Regression] __builtin_object_size (..., 1) fails to locate
subobject

Reply via email to