> > > diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md > > > index fb677e17817..f3fbed81c4a 100644 > > > --- a/gcc/config/i386/i386.md > > > +++ b/gcc/config/i386/i386.md > > > @@ -18007,7 +18007,13 @@ (define_expand "cmpstrnsi" > > > { > > > rtx addr1, addr2, countreg, align, out; > > > > > > - if (optimize_insn_for_size_p () && !TARGET_INLINE_ALL_STRINGOPS) > > > + /* Expand strncmp only with -minline-all-stringops since > > > + "repz cmpsb" can be much slower than strncmp functions > > > + implemented with vector instructions, see > > > + > > > + https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43052 > > > + */ > > > + if (!TARGET_INLINE_ALL_STRINGOPS) > > > FAIL;
I think this is hitting the more general problem that we want to have two levels of optimization for size (at least internally). One for parts of program guessed to be cold and do not perform such extreme changes (i.e. translate stringops, division etc.) and other when we really want top optimize for size. I will try to push out patches for two-state optimize_size next week. Honza > > > > > > /* Can't use this if the user has appropriated ecx, esi or edi. */ > > > diff --git a/gcc/testsuite/gcc.target/i386/pr95458-1.c > > > b/gcc/testsuite/gcc.target/i386/pr95458-1.c > > > new file mode 100644 > > > index 00000000000..231a4787dce > > > --- /dev/null > > > +++ b/gcc/testsuite/gcc.target/i386/pr95458-1.c > > > @@ -0,0 +1,11 @@ > > > +/* { dg-do compile } */ > > > +/* { dg-options "-O2 -minline-all-stringops" } */ > > > + > > > +int > > > +func (char *d, unsigned int l) > > > +{ > > > + return __builtin_strncmp (d, "foo", l) ? 1 : 2; > > > +} > > > + > > > +/* { dg-final { scan-assembler-not "call\[\\t \]*_?strncmp" } } */ > > > +/* { dg-final { scan-assembler "cmpsb" } } */ > > > diff --git a/gcc/testsuite/gcc.target/i386/pr95458-2.c > > > b/gcc/testsuite/gcc.target/i386/pr95458-2.c > > > new file mode 100644 > > > index 00000000000..1a620444770 > > > --- /dev/null > > > +++ b/gcc/testsuite/gcc.target/i386/pr95458-2.c > > > @@ -0,0 +1,7 @@ > > > +/* { dg-do compile } */ > > > +/* { dg-options "-O2 -mno-inline-all-stringops" } */ > > > + > > > +#include "pr95458-1.c" > > > + > > > +/* { dg-final { scan-assembler "call\[\\t \]*_?strncmp" } } */ > > > +/* { dg-final { scan-assembler-not "cmpsb" } } */ > > > -- > > > 2.26.2 > > > > > > > PING. > > PING. > > -- > H.J.