aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-rw-r--r--gcc/config/i386/i386-expand.c19
-rw-r--r--gcc/testsuite/gcc.target/i386/pr95458-1.c11
-rw-r--r--gcc/testsuite/gcc.target/i386/pr95458-2.c7
3 files changed, 25 insertions, 12 deletions
diff --git a/gcc/config/i386/i386-expand.c b/gcc/config/i386/i386-expand.c
index bd83a8e..19a9f2d 100644
--- a/gcc/config/i386/i386-expand.c
+++ b/gcc/config/i386/i386-expand.c
@@ -7679,7 +7679,13 @@ bool
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. */
@@ -7706,17 +7712,6 @@ ix86_expand_cmpstrn_or_cmpmem (rtx result, rtx src1, rtx src2,
== 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));
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 0000000..231a478
--- /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 0000000..1a62044
--- /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" } } */