aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2018-05-30 07:19:24 +0000
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2018-05-30 07:19:24 +0000
commitfa8bfbd8bb474c20264acb9f55734ee6929e0262 (patch)
tree51fb0ceed53fe3d7960ad2cc4d34fcc14aa869a2
parent10544a955c2679a36fe5147fdfe63e9b7e280031 (diff)
Backported from mainline
2018-05-08 Jakub Jelinek <jakub@redhat.com> PR target/85683 * config/i386/i386.md: Add peepholes for mem {+,-,&,|,^}= x; mem != 0 after cmpelim optimization. * gcc.target/i386/pr49095.c: Add -masm=att to dg-options. Add scan-assembler-times checking that except for [fh]*xor other functions don't use any load instructions. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-8-branch@260915 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog9
-rw-r--r--gcc/config/i386/i386.md59
-rw-r--r--gcc/testsuite/ChangeLog10
-rw-r--r--gcc/testsuite/gcc.target/i386/pr49095.c5
4 files changed, 82 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index bfeb2347304..c42ce78d17d 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,12 @@
+2018-05-30 Jakub Jelinek <jakub@redhat.com>
+
+ Backported from mainline
+ 2018-05-08 Jakub Jelinek <jakub@redhat.com>
+
+ PR target/85683
+ * config/i386/i386.md: Add peepholes for mem {+,-,&,|,^}= x; mem != 0
+ after cmpelim optimization.
+
2018-05-28 H.J. Lu <hongjiu.lu@intel.com>
Backport from mainline
diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md
index ad9ccf9d1d7..c01d87885cf 100644
--- a/gcc/config/i386/i386.md
+++ b/gcc/config/i386/i386.md
@@ -19073,6 +19073,37 @@
const0_rtx);
})
+;; Likewise for cmpelim optimized pattern.
+(define_peephole2
+ [(set (match_operand:SWI 0 "register_operand")
+ (match_operand:SWI 1 "memory_operand"))
+ (parallel [(set (reg FLAGS_REG)
+ (compare (match_operator:SWI 3 "plusminuslogic_operator"
+ [(match_dup 0)
+ (match_operand:SWI 2 "<nonmemory_operand>")])
+ (const_int 0)))
+ (set (match_dup 0) (match_dup 3))])
+ (set (match_dup 1) (match_dup 0))]
+ "(TARGET_READ_MODIFY_WRITE || optimize_insn_for_size_p ())
+ && peep2_reg_dead_p (3, operands[0])
+ && !reg_overlap_mentioned_p (operands[0], operands[1])
+ && !reg_overlap_mentioned_p (operands[0], operands[2])
+ && ix86_match_ccmode (peep2_next_insn (1),
+ (GET_CODE (operands[3]) == PLUS
+ || GET_CODE (operands[3]) == MINUS)
+ ? CCGOCmode : CCNOmode)"
+ [(parallel [(set (match_dup 4) (match_dup 6))
+ (set (match_dup 1) (match_dup 5))])]
+{
+ operands[4] = SET_DEST (XVECEXP (PATTERN (peep2_next_insn (1)), 0, 0));
+ operands[5]
+ = gen_rtx_fmt_ee (GET_CODE (operands[3]), GET_MODE (operands[3]),
+ copy_rtx (operands[1]), operands[2]);
+ operands[6]
+ = gen_rtx_COMPARE (GET_MODE (operands[4]), copy_rtx (operands[5]),
+ const0_rtx);
+})
+
;; Likewise for instances where we have a lea pattern.
(define_peephole2
[(set (match_operand:SWI 0 "register_operand")
@@ -19136,6 +19167,34 @@
const0_rtx);
})
+;; Likewise for cmpelim optimized pattern.
+(define_peephole2
+ [(parallel [(set (reg FLAGS_REG)
+ (compare (match_operator:SWI 2 "plusminuslogic_operator"
+ [(match_operand:SWI 0 "register_operand")
+ (match_operand:SWI 1 "memory_operand")])
+ (const_int 0)))
+ (set (match_dup 0) (match_dup 2))])
+ (set (match_dup 1) (match_dup 0))]
+ "(TARGET_READ_MODIFY_WRITE || optimize_insn_for_size_p ())
+ && peep2_reg_dead_p (2, operands[0])
+ && !reg_overlap_mentioned_p (operands[0], operands[1])
+ && ix86_match_ccmode (peep2_next_insn (0),
+ (GET_CODE (operands[2]) == PLUS
+ || GET_CODE (operands[2]) == MINUS)
+ ? CCGOCmode : CCNOmode)"
+ [(parallel [(set (match_dup 3) (match_dup 5))
+ (set (match_dup 1) (match_dup 4))])]
+{
+ operands[3] = SET_DEST (XVECEXP (PATTERN (peep2_next_insn (0)), 0, 0));
+ operands[4]
+ = gen_rtx_fmt_ee (GET_CODE (operands[2]), GET_MODE (operands[2]),
+ copy_rtx (operands[1]), operands[0]);
+ operands[5]
+ = gen_rtx_COMPARE (GET_MODE (operands[3]), copy_rtx (operands[4]),
+ const0_rtx);
+})
+
(define_peephole2
[(set (match_operand:SWI12 0 "register_operand")
(match_operand:SWI12 1 "memory_operand"))
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 99d4ba08373..d9d472ca387 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,13 @@
+2018-05-30 Jakub Jelinek <jakub@redhat.com>
+
+ Backported from mainline
+ 2018-05-08 Jakub Jelinek <jakub@redhat.com>
+
+ PR target/85683
+ * gcc.target/i386/pr49095.c: Add -masm=att to dg-options. Add
+ scan-assembler-times checking that except for [fh]*xor other functions
+ don't use any load instructions.
+
2018-05-28 H.J. Lu <hongjiu.lu@intel.com>
Backport from mainline
diff --git a/gcc/testsuite/gcc.target/i386/pr49095.c b/gcc/testsuite/gcc.target/i386/pr49095.c
index 73758f8c523..07807191063 100644
--- a/gcc/testsuite/gcc.target/i386/pr49095.c
+++ b/gcc/testsuite/gcc.target/i386/pr49095.c
@@ -1,6 +1,6 @@
/* PR rtl-optimization/49095 */
/* { dg-do compile } */
-/* { dg-options "-Os -fno-shrink-wrap" } */
+/* { dg-options "-Os -fno-shrink-wrap -masm=att" } */
/* { dg-additional-options "-mregparm=2" { target ia32 } } */
void foo (void *);
@@ -71,3 +71,6 @@ G (int)
G (long)
/* { dg-final { scan-assembler-not "test\[lq\]" } } */
+/* The {f,h}{char,short,int,long}xor functions aren't optimized into
+ a RMW instruction, so need load, modify and store. FIXME eventually. */
+/* { dg-final { scan-assembler-times "\\), %" 8 } } */