ix86_expand_cmpstrn_or_cmpmem (rtx result, rtx src1, rtx src2,
rtx length, rtx align, bool is_cmpstrn)
{
- if (optimize_insn_for_size_p () && !TARGET_INLINE_ALL_STRINGOPS)
+ /* Expand strncmp and memcmp only with -minline-all-stringops since
+ "repz cmpsb" can be much slower than strncmp and memcmp functions
+ implemented with vector instructions, see
+
+ https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43052
+ */
+ if (!TARGET_INLINE_ALL_STRINGOPS)
return false;
/* Can't use this if the user has appropriated ecx, esi or edi. */
== STRING_CST))))
return false;
}
- else
- {
- /* Expand memcmp to "repz cmpsb" only for -minline-all-stringops
- since "repz cmpsb" can be much slower than memcmp function
- implemented with vector instructions, see
-
- https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43052
- */
- if (!TARGET_INLINE_ALL_STRINGOPS)
- return false;
- }
rtx addr1 = copy_addr_to_reg (XEXP (src1, 0));
rtx addr2 = copy_addr_to_reg (XEXP (src2, 0));
--- /dev/null
+/* { 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" } } */
--- /dev/null
+/* { 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" } } */