]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
rs6000: Call library for block memory compare when optimizing for size
authorHaochen Gui <guihaoc@gcc.gnu.org>
Wed, 27 Dec 2023 02:30:56 +0000 (10:30 +0800)
committerHaochen Gui <guihaoc@gcc.gnu.org>
Wed, 27 Dec 2023 02:35:14 +0000 (10:35 +0800)
gcc/
* config/rs6000/rs6000.md (cmpmemsi): Fail when optimizing for size.

gcc/testsuite/
* gcc.target/powerpc/block-cmp-3.c: New.

gcc/config/rs6000/rs6000.md
gcc/testsuite/gcc.target/powerpc/block-cmp-3.c [new file with mode: 0644]

index 58126628ca04e4f87bebecab431f791401d5f8e8..37e427bd37b44c8e837f4dfb239e6483860cb12f 100644 (file)
              (use (match_operand:SI 4))])]
   "TARGET_POPCNTD"
 {
+  if (optimize_insn_for_size_p ())
+    FAIL;
+
   if (expand_block_compare (operands))
     DONE;
   else
diff --git a/gcc/testsuite/gcc.target/powerpc/block-cmp-3.c b/gcc/testsuite/gcc.target/powerpc/block-cmp-3.c
new file mode 100644 (file)
index 0000000..c7e853a
--- /dev/null
@@ -0,0 +1,8 @@
+/* { dg-do compile } */
+/* { dg-options "-Os" } */
+/* { dg-final { scan-assembler-times {\mb[l]? memcmp\M} 1 } }  */
+
+int foo (const char* s1, const char* s2)
+{
+  return __builtin_memcmp (s1, s2, 4);
+}