re PR rtl-optimization/70467 (Useless "and [esp],-1" emitted on AND with uint64_t...
authorJakub Jelinek <jakub@redhat.com>
Fri, 1 Apr 2016 16:08:21 +0000 (18:08 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 1 Apr 2016 16:08:21 +0000 (18:08 +0200)
PR rtl-optimization/70467
* config/i386/i386.md (*add<dwi>3_doubleword, *sub<dwi>3_doubleword):
If low word of the last operand is 0, just emit addition/subtraction
for the high word.

* gcc.target/i386/pr70467-2.c: New test.

From-SVN: r234679

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

index de3b8c575434954f5c5f4fbf9ef3819e719c84ba..81d8879747275515426b75b1a350d4f1ea64b172 100644 (file)
@@ -1,3 +1,10 @@
+2016-04-01  Jakub Jelinek  <jakub@redhat.com>
+
+       PR rtl-optimization/70467
+       * config/i386/i386.md (*add<dwi>3_doubleword, *sub<dwi>3_doubleword):
+       If low word of the last operand is 0, just emit addition/subtraction
+       for the high word.
+
 2016-04-01  Andreas Krebbel  <krebbel@linux.vnet.ibm.com>
 
        PR target/70404
index f324ea7ea4198b0d1765a60b54305a4fb95e3272..09da69e7e44d184fe60c9e97635a90b61732d339 100644 (file)
                       (match_dup 4))
                     (match_dup 5)))
              (clobber (reg:CC FLAGS_REG))])]
-  "split_double_mode (<DWI>mode, &operands[0], 3, &operands[0], &operands[3]);")
+{
+  split_double_mode (<DWI>mode, &operands[0], 3, &operands[0], &operands[3]);
+  if (operands[2] == const0_rtx)
+    {
+      ix86_expand_binary_operator (PLUS, <MODE>mode, &operands[3]);
+      DONE;
+    }
+})
 
 (define_insn "*add<mode>_1"
   [(set (match_operand:SWI48 0 "nonimmediate_operand" "=r,rm,r,r")
                       (ltu:DWIH (reg:CC FLAGS_REG) (const_int 0)))
                     (match_dup 5)))
              (clobber (reg:CC FLAGS_REG))])]
-  "split_double_mode (<DWI>mode, &operands[0], 3, &operands[0], &operands[3]);")
+{
+  split_double_mode (<DWI>mode, &operands[0], 3, &operands[0], &operands[3]);
+  if (operands[2] == const0_rtx)
+    {
+      ix86_expand_binary_operator (MINUS, <MODE>mode, &operands[3]);
+      DONE;
+    }
+})
 
 (define_insn "*sub<mode>_1"
   [(set (match_operand:SWI 0 "nonimmediate_operand" "=<r>m,<r>")
index a4a1df51afcfe123091ee652a82d6a70485b2860..e908caaf4d1ebdd51e8dddbe5bc016e5e4f5db43 100644 (file)
@@ -1,3 +1,8 @@
+2016-04-01  Jakub Jelinek  <jakub@redhat.com>
+
+       PR rtl-optimization/70467
+       * gcc.target/i386/pr70467-2.c: New test.
+
 2016-04-01  Jakub Jelinek  <jakub@redhat.com>
            Marek Polacek  <polacek@redhat.com>
 
diff --git a/gcc/testsuite/gcc.target/i386/pr70467-2.c b/gcc/testsuite/gcc.target/i386/pr70467-2.c
new file mode 100644 (file)
index 0000000..4c1715c
--- /dev/null
@@ -0,0 +1,20 @@
+/* PR rtl-optimization/70467 */
+/* { dg-do compile { target ia32 } } */
+/* { dg-options "-O2" } */
+
+unsigned long long
+foo (unsigned long long x)
+{
+  return x + 0x12345600000000ULL;
+}
+
+unsigned long long
+bar (unsigned long long x)
+{
+  return x - 0x12345600000000ULL;
+}
+
+/* { dg-final { scan-assembler-not "addl\[ \t\]*.0," } } */
+/* { dg-final { scan-assembler-not "subl\[ \t\]*.0," } } */
+/* { dg-final { scan-assembler-not "adcl\[^\n\r\]*%" } } */
+/* { dg-final { scan-assembler-not "sbbl\[^\n\r\]*%" } } */