From 1855f812512d84eca88c51c1ceac0045bc95ad5e Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Thu, 19 Oct 2017 10:37:04 +0200 Subject: [PATCH] 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 --- gcc/ChangeLog | 6 +++ gcc/config/i386/i386.md | 57 +++++++++++++++++++++++++ gcc/testsuite/ChangeLog | 7 +++ gcc/testsuite/gcc.target/i386/pr82580.c | 3 +- 4 files changed, 72 insertions(+), 1 deletion(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 91a29170225..b7f4e4e071c 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2017-10-19 Jakub Jelinek + + 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 * doc/sourcebuild.texi (Test Directives, Variants of diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md index 57a90dbe041..6fed9b8786a 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 37bee72ffb5..8416e7a1636 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2017-10-19 Jakub Jelinek + + 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 * 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 ce4bf9230a8..965dfeec28d 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 } } } */ -- 2.30.2