re PR target/82618 (Inefficient double-word subtraction on x86_64)
authorUros Bizjak <ubizjak@gmail.com>
Thu, 19 Oct 2017 17:35:39 +0000 (19:35 +0200)
committerUros Bizjak <uros@gcc.gnu.org>
Thu, 19 Oct 2017 17:35:39 +0000 (19:35 +0200)
PR target/82618
* config/i386/i386.md (sub to cmp): New peephole2 pattern.

testsuite/ChangeLog:

PR target/82618
* gcc.target/i386/pr82618.c: New test.

Co-Authored-By: Jakub Jelinek <jakub@redhat.com>
From-SVN: r253905

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

index c37cddbb8f71c9bb93c923eda11dc3a73c3a32a0..b3740b54d71c381fb346fc559ff6cf9a4428bc4b 100644 (file)
@@ -1,3 +1,8 @@
+2017-10-19  Uros Bizjak  <ubizjak@gmail.com>
+
+       PR target/82618
+       * config/i386/i386.md (sub to cmp): New peephole2 pattern.
+
 2017-10-19  Alexander Monakov  <amonakov@ispras.ru>
 
        PR rtl-optimization/82395
index 6fed9b8786ae027eb3a9161c3f0ea0817b23ee6e..d9097211713e78f96f693feb95abd851c15f51c9 100644 (file)
   [(set_attr "type" "alu")
    (set_attr "mode" "<MODE>")])
 
+(define_peephole2
+  [(parallel
+     [(set (reg:CC FLAGS_REG)
+          (compare:CC (match_operand:SWI 0 "general_reg_operand")
+                      (match_operand:SWI 1 "general_gr_operand")))
+      (set (match_dup 0)
+          (minus:SWI (match_dup 0) (match_dup 1)))])]
+  "find_regno_note (peep2_next_insn (0), REG_UNUSED, REGNO (operands[0])) != 0"
+  [(set (reg:CC FLAGS_REG)
+       (compare:CC (match_dup 0) (match_dup 1)))])
+
 (define_insn "*subsi_3_zext"
   [(set (reg FLAGS_REG)
        (compare (match_operand:SI 1 "register_operand" "0")
index 31cf70bbfcb425afb21276d01fac8507e64fcd48..8ef91aadc878b76a157aab9db4a49224d5661e11 100644 (file)
@@ -1,3 +1,9 @@
+2017-10-18  Uros Bizjak  <ubizjak@gmail.com>
+           Jakub Jelinek  <jakub@redhat.com>
+
+       PR target/82618
+       * gcc.target/i386/pr82618.c: New test.
+
 2017-10-19  Martin Sebor  <msebor@redhat.com>
 
        PR tree-optimization/82596
diff --git a/gcc/testsuite/gcc.target/i386/pr82618.c b/gcc/testsuite/gcc.target/i386/pr82618.c
new file mode 100644 (file)
index 0000000..f6e3589
--- /dev/null
@@ -0,0 +1,18 @@
+/* PR target/82618 */
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+#ifdef __SIZEOF_INT128__
+typedef unsigned __int128 U;
+typedef unsigned long long H;
+#else
+typedef unsigned long long U;
+typedef unsigned int H;
+#endif
+
+H f0 (U x, U y)
+{
+  return (x - y) >> (__CHAR_BIT__ * sizeof (H));
+}
+
+/* { dg-final { scan-assembler {\mcmp} } } */