[Bug tree-optimization/83543] strlen of a local array member not optimized on some targets

msebor at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Fri Dec 22 00:27:00 GMT 2017


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

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |missed-optimization

--- Comment #1 from Martin Sebor <msebor at gcc dot gnu.org> ---
On powerpc64le the root cause of the failure to optimize the code is in the
strlen pass not handling the struct initialization

  struct S s = { "12345" };

represented as struct assignment (s = *.LC0 below).  The pass only handles
assignment to individual struct members (which is how the initialization is
represented on x86_64).

f ()
{
  struct S s;
  long unsigned int _1;

  <bb 2> [local count: 1073741825]:
  s = *.LC0;
  ...

To enable the optimization in this case the pass needs to be extended to handle
the assignment from a constant VAR_DECL with an initial value (a CONSTRUCTOR).


More information about the Gcc-bugs mailing list