[Bug target/79144] cmpstrnsi optimization breaks glibc

2017-01-19 Thread amodra at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79144

Alan Modra  changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 Resolution|--- |FIXED
   Target Milestone|--- |7.0

--- Comment #4 from Alan Modra  ---
Fixed

[Bug target/79144] cmpstrnsi optimization breaks glibc

2017-01-19 Thread amodra at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79144

--- Comment #3 from Alan Modra  ---
Author: amodra
Date: Thu Jan 19 23:19:19 2017
New Revision: 244659

URL: https://gcc.gnu.org/viewcvs?rev=244659=gcc=rev
Log:
[RS6000] PR79144, cmpstrnsi optimization breaks glibc

glibc compiled with current gcc-7 fails one test due to strcmp and
strncmp appearing in the PLT.  This is because the inline expansion of
those functions falls back to a function call, but doesn't use the asm
name for the call.

PR target/79144
* config/rs6000/rs6000.c (expand_strn_compare): Get the asm name
for strcmp and strncmp from corresponding builtin decl.

Modified:
trunk/gcc/ChangeLog
trunk/gcc/config/rs6000/rs6000.c

[Bug target/79144] cmpstrnsi optimization breaks glibc

2017-01-19 Thread acsawdey at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79144

--- Comment #2 from acsawdey at gcc dot gnu.org ---
Alan,
  Thanks for jumping in here. What I tried yesterday was this code to try to
get the correct name:

+ const char *id =
+   IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME
+   (builtin_decl_explicit (BUILT_IN_STRCMP)));
+ if (id == NULL || *id == 0)
+   id = "strcmp";
+ else if (*id == '*')
+   id++;
+ emit_library_call_value (gen_rtx_SYMBOL_REF (Pmode, id),
+  target, LCT_NORMAL, GET_MODE (target), 2,
+  force_reg (Pmode, XEXP (src1, 0)), Pmode,
+  force_reg (Pmode, XEXP (src2, 0)), Pmode);

But this didn't work for reasons I don't quite understand.

The other discussion of this starts here on gcc-patches:

https://gcc.gnu.org/ml/gcc-patches/2017-01/msg00843.html

[Bug target/79144] cmpstrnsi optimization breaks glibc

2017-01-19 Thread amodra at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79144

Alan Modra  changed:

   What|Removed |Added

 Status|UNCONFIRMED |ASSIGNED
   Last reconfirmed||2017-01-19
   Assignee|unassigned at gcc dot gnu.org  |amodra at gmail dot com
 Ever confirmed|0   |1

--- Comment #1 from Alan Modra  ---
Testing a fix