aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2017-10-19 10:37:04 +0200
committerJakub Jelinek <jakub@gcc.gnu.org>2017-10-19 10:37:04 +0200
commit1855f812512d84eca88c51c1ceac0045bc95ad5e (patch)
treee4479516274dc8ab14def1e71fba5b975ba80468
parent8a78f1a1b6bc31b0897107bd32cc8cffa3187070 (diff)
downloadgcc-1855f812512d84eca88c51c1ceac0045bc95ad5e.zip
gcc-1855f812512d84eca88c51c1ceac0045bc95ad5e.tar.gz
gcc-1855f812512d84eca88c51c1ceac0045bc95ad5e.tar.bz2
re PR target/82580 (Optimize comparisons for __int128 on x86-64)
PR target/82580 * config/i386/i386.md (setcc + movzbl to xor + setcc): New peephole2. (setcc + and to xor + setcc): New peephole2. * gcc.target/i386/pr82580.c: Use {\msbb} instead of "sbb" in scan-assembler-times. Check that there are no movzb* instructions if lp64. From-SVN: r253884
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/config/i386/i386.md57
-rw-r--r--gcc/testsuite/ChangeLog7
-rw-r--r--gcc/testsuite/gcc.target/i386/pr82580.c3
4 files changed, 72 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 91a2917..b7f4e4e 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2017-10-19 Jakub Jelinek <jakub@redhat.com>
+
+ PR target/82580
+ * config/i386/i386.md (setcc + movzbl to xor + setcc): New peephole2.
+ (setcc + and to xor + setcc): New peephole2.
+
2017-10-19 Tom de Vries <tom@codesourcery.com>
* doc/sourcebuild.texi (Test Directives, Variants of
diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md
index 57a90db..6fed9b8 100644
--- a/gcc/config/i386/i386.md
+++ b/gcc/config/i386/i386.md
@@ -12300,6 +12300,34 @@
ix86_expand_clear (operands[3]);
})
+(define_peephole2
+ [(set (reg FLAGS_REG) (match_operand 0))
+ (parallel [(set (reg FLAGS_REG) (match_operand 1))
+ (match_operand 5)])
+ (set (match_operand:QI 2 "register_operand")
+ (match_operator:QI 3 "ix86_comparison_operator"
+ [(reg FLAGS_REG) (const_int 0)]))
+ (set (match_operand 4 "any_QIreg_operand")
+ (zero_extend (match_dup 2)))]
+ "(peep2_reg_dead_p (4, operands[2])
+ || operands_match_p (operands[2], operands[4]))
+ && ! reg_overlap_mentioned_p (operands[4], operands[0])
+ && ! reg_overlap_mentioned_p (operands[4], operands[1])
+ && ! reg_set_p (operands[4], operands[5])
+ && refers_to_regno_p (FLAGS_REG, operands[1], (rtx *)NULL)
+ && peep2_regno_dead_p (0, FLAGS_REG)"
+ [(set (match_dup 6) (match_dup 0))
+ (parallel [(set (match_dup 7) (match_dup 1))
+ (match_dup 5)])
+ (set (strict_low_part (match_dup 8))
+ (match_dup 3))]
+{
+ operands[6] = gen_rtx_REG (GET_MODE (operands[0]), FLAGS_REG);
+ operands[7] = gen_rtx_REG (GET_MODE (operands[1]), FLAGS_REG);
+ operands[8] = gen_lowpart (QImode, operands[4]);
+ ix86_expand_clear (operands[4]);
+})
+
;; Similar, but match zero extend with andsi3.
(define_peephole2
@@ -12345,6 +12373,35 @@
operands[6] = gen_lowpart (QImode, operands[3]);
ix86_expand_clear (operands[3]);
})
+
+(define_peephole2
+ [(set (reg FLAGS_REG) (match_operand 0))
+ (parallel [(set (reg FLAGS_REG) (match_operand 1))
+ (match_operand 5)])
+ (set (match_operand:QI 2 "register_operand")
+ (match_operator:QI 3 "ix86_comparison_operator"
+ [(reg FLAGS_REG) (const_int 0)]))
+ (parallel [(set (match_operand 4 "any_QIreg_operand")
+ (zero_extend (match_dup 2)))
+ (clobber (reg:CC FLAGS_REG))])]
+ "(peep2_reg_dead_p (4, operands[2])
+ || operands_match_p (operands[2], operands[4]))
+ && ! reg_overlap_mentioned_p (operands[4], operands[0])
+ && ! reg_overlap_mentioned_p (operands[4], operands[1])
+ && ! reg_set_p (operands[4], operands[5])
+ && refers_to_regno_p (FLAGS_REG, operands[1], (rtx *)NULL)
+ && peep2_regno_dead_p (0, FLAGS_REG)"
+ [(set (match_dup 6) (match_dup 0))
+ (parallel [(set (match_dup 7) (match_dup 1))
+ (match_dup 5)])
+ (set (strict_low_part (match_dup 8))
+ (match_dup 3))]
+{
+ operands[6] = gen_rtx_REG (GET_MODE (operands[0]), FLAGS_REG);
+ operands[7] = gen_rtx_REG (GET_MODE (operands[1]), FLAGS_REG);
+ operands[8] = gen_lowpart (QImode, operands[4]);
+ ix86_expand_clear (operands[4]);
+})
;; Call instructions.
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 37bee72..8416e7a 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,10 @@
+2017-10-19 Jakub Jelinek <jakub@redhat.com>
+
+ PR target/82580
+ * gcc.target/i386/pr82580.c: Use {\msbb} instead of "sbb" in
+ scan-assembler-times. Check that there are no movzb* instructions
+ if lp64.
+
2017-10-19 Tom de Vries <tom@codesourcery.com>
* gcc.dg/tree-ssa/ldist-27.c: Use dg-require-stack-size.
diff --git a/gcc/testsuite/gcc.target/i386/pr82580.c b/gcc/testsuite/gcc.target/i386/pr82580.c
index ce4bf92..965dfee 100644
--- a/gcc/testsuite/gcc.target/i386/pr82580.c
+++ b/gcc/testsuite/gcc.target/i386/pr82580.c
@@ -35,4 +35,5 @@ void f21 (S x, S y) { if (x >= y) bar (); }
void f22 (S x, S y) { if (x < y) bar (); }
void f23 (S x, S y) { if (x <= y) bar (); }
-/* { dg-final { scan-assembler-times "sbb" 16 } } */
+/* { dg-final { scan-assembler-times {\msbb} 16 } } */
+/* { dg-final { scan-assembler-not {\mmovzb} { target lp64 } } } */