re PR target/92549 (Use x86 xchg instruction more)
authorJakub Jelinek <jakub@redhat.com>
Tue, 19 Nov 2019 09:31:59 +0000 (10:31 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 19 Nov 2019 09:31:59 +0000 (10:31 +0100)
PR target/92549
* config/i386/i386.md (peephole2 for *swap<mode>): New peephole2.

* gcc.target/i386/pr92549.c: New test.

From-SVN: r278439

gcc/ChangeLog
gcc/config/i386/i386.md
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/i386/pr92549.c [new file with mode: 0644]

index 6560a39c7055510c1bfd6f54908bd5b01a31b451..df949f184753742421169b483f8fb55bb6ffe9fb 100644 (file)
@@ -1,5 +1,8 @@
 2019-11-19  Jakub Jelinek  <jakub@redhat.com>
 
+       PR target/92549
+       * config/i386/i386.md (peephole2 for *swap<mode>): New peephole2.
+
        PR middle-end/91450
        * internal-fn.c (expand_mul_overflow): For s1 * s2 -> ur, if one
        operand is negative and one non-negative, compare the non-negative
index fb2235a5e347a915c2fb8a02d52662bc9bc44e48..7ff5872ba436c9adc6393f57a9958fc57e80de7e 100644 (file)
    (set_attr "amdfam10_decode" "double")
    (set_attr "bdver1_decode" "double")])
 
+(define_peephole2
+  [(set (match_operand:SWI 0 "register_operand")
+       (match_operand:SWI 1 "register_operand"))
+   (set (match_dup 1)
+       (match_operand:SWI 2 "register_operand"))
+   (set (match_dup 2) (match_dup 0))]
+  "peep2_reg_dead_p (3, operands[0])
+   && optimize_insn_for_size_p ()"
+  [(parallel [(set (match_dup 1) (match_dup 2))
+             (set (match_dup 2) (match_dup 1))])])
+
 (define_expand "movstrict<mode>"
   [(set (strict_low_part (match_operand:SWI12 0 "register_operand"))
        (match_operand:SWI12 1 "general_operand"))]
index 16a410605eeec3162d745caaaa4414a25e50beab..51e8e1fc1c56329670a2d5b0f8a95d37851e0bba 100644 (file)
@@ -1,5 +1,8 @@
 2019-11-19  Jakub Jelinek  <jakub@redhat.com>
 
+       PR target/92549
+       * gcc.target/i386/pr92549.c: New test.
+
        PR middle-end/91450
        * gcc.c-torture/execute/pr91450-1.c: New test.
        * gcc.c-torture/execute/pr91450-2.c: New test.
diff --git a/gcc/testsuite/gcc.target/i386/pr92549.c b/gcc/testsuite/gcc.target/i386/pr92549.c
new file mode 100644 (file)
index 0000000..c6c6bb8
--- /dev/null
@@ -0,0 +1,17 @@
+/* PR target/92549 */
+/* { dg-do compile } */
+/* { dg-options "-Os -masm=att" } */
+/* { dg-additional-options "-mregparm=2" { target ia32 } } */
+/* { dg-final { scan-assembler "xchgl" } } */
+
+__attribute__((noipa)) int
+bar (int a, int b)
+{
+  return b - a + 5;
+}
+
+int
+foo (int a, int b)
+{
+  return 1 + bar (b, a);
+}