summaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorkazu <kazu@138bc75d-0d04-0410-961f-82ee72b054a4>2003-06-21 11:32:54 +0000
committerkazu <kazu@138bc75d-0d04-0410-961f-82ee72b054a4>2003-06-21 11:32:54 +0000
commit8c71b4e998e3b3de3bec1979a1277034e39a9b0a (patch)
tree00058e7b86dfbfc4a04d85cd255b60893f0418ff /gcc
parent88d71f6dd7fdea1b96d76be8af249d142a7ab492 (diff)
downloadgcc-8c71b4e998e3b3de3bec1979a1277034e39a9b0a.tar.gz
* config/h8300/h8300-protos.h: Add a prototype for
same_cmp_preceding_p. * config/h8300/h8300.c (same_cmp_preceding): New. * config/h8300/h8300.md: Extend peephole2's that transform compare:SI into shorter sequences so that they can deal with signed comparisons. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@68296 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog9
-rw-r--r--gcc/config/h8300/h8300-protos.h1
-rw-r--r--gcc/config/h8300/h8300.c20
-rw-r--r--gcc/config/h8300/h8300.md81
4 files changed, 86 insertions, 25 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index fb790a70682..640677a50b9 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,12 @@
+2003-06-20 Kazu Hirata <kazu@cs.umass.edu>
+
+ * config/h8300/h8300-protos.h: Add a prototype for
+ same_cmp_preceding_p.
+ * config/h8300/h8300.c (same_cmp_preceding): New.
+ * config/h8300/h8300.md: Extend peephole2's that transform
+ compare:SI into shorter sequences so that they can deal with
+ signed comparisons.
+
2003-06-14 Gerald Pfeifer <pfeifer@dbai.tuwien.ac.at>
* doc/contrib.texi (Contributors): Use Windows instead of Win32.
diff --git a/gcc/config/h8300/h8300-protos.h b/gcc/config/h8300/h8300-protos.h
index b86b8ab1dc8..d1708698bb2 100644
--- a/gcc/config/h8300/h8300-protos.h
+++ b/gcc/config/h8300/h8300-protos.h
@@ -76,6 +76,7 @@ extern int iorxor_operator (rtx, enum machine_mode);
extern int h8300_eightbit_constant_address_p (rtx);
extern int h8300_tiny_constant_address_p (rtx);
extern int byte_accesses_mergeable_p (rtx, rtx);
+extern int same_cmp_preceding_p (rtx);
/* Used in builtins.c */
extern rtx h8300_return_addr_rtx (int, rtx);
diff --git a/gcc/config/h8300/h8300.c b/gcc/config/h8300/h8300.c
index 826cd6ca9bb..d7a55f17cf2 100644
--- a/gcc/config/h8300/h8300.c
+++ b/gcc/config/h8300/h8300.c
@@ -4335,6 +4335,26 @@ byte_accesses_mergeable_p (rtx addr1, rtx addr2)
return 0;
}
+
+/* Return nonzero if we have the same comparison insn as I3 two insns
+ before I3. I3 is assumed to be a comparision insn. */
+
+int
+same_cmp_preceding_p (rtx i3)
+{
+ rtx i1, i2;
+
+ /* Make sure we have a sequence of three insns. */
+ i2 = prev_nonnote_insn (i3);
+ if (i2 == NULL_RTX)
+ return 0;
+ i1 = prev_nonnote_insn (i2);
+ if (i1 == NULL_RTX)
+ return 0;
+
+ return (INSN_P (i1) && rtx_equal_p (PATTERN (i1), PATTERN (i3))
+ && any_condjump_p (i2) && onlyjump_p (i2));
+}
/* Initialize the GCC target structure. */
#undef TARGET_ATTRIBUTE_TABLE
diff --git a/gcc/config/h8300/h8300.md b/gcc/config/h8300/h8300.md
index 6ec03c386d9..cae57370bf0 100644
--- a/gcc/config/h8300/h8300.md
+++ b/gcc/config/h8300/h8300.md
@@ -3968,8 +3968,8 @@
;; dead 1 eq/ne dec.l
;; dead 2 eq/ne dec.l
;;
-;; dead 1 geu/ltu shlr.l
-;; dead 3 (H8S) geu/ltu shlr.l
+;; dead 1 geu/ltu shar.l
+;; dead 3 (H8S) geu/ltu shar.l
;;
;; ---- 255 geu/ltu mov.b
@@ -4013,7 +4013,7 @@
;;
;; into
;;
-;; shlr.w r0
+;; shar.w r0
;; bne .L1
(define_peephole2
@@ -4021,7 +4021,7 @@
(compare (match_operand:HI 0 "register_operand" "")
(match_operand:HI 1 "const_int_operand" "")))
(set (pc)
- (if_then_else (match_operator 2 "gtuleu_operator"
+ (if_then_else (match_operator 2 "gtle_operator"
[(cc0) (const_int 0)])
(label_ref (match_operand 3 "" ""))
(pc)))]
@@ -4030,7 +4030,7 @@
&& (INTVAL (operands[1]) == 1
|| (TARGET_H8300S && INTVAL (operands[1]) == 3))"
[(parallel [(set (match_dup 0)
- (lshiftrt:HI (match_dup 0)
+ (ashiftrt:HI (match_dup 0)
(match_dup 5)))
(clobber (scratch:QI))])
(set (cc0)
@@ -4039,9 +4039,18 @@
(if_then_else (match_dup 4)
(label_ref (match_dup 3))
(pc)))]
- "operands[4] = ((GET_CODE (operands[2]) == GTU) ?
- gen_rtx_NE (VOIDmode, cc0_rtx, const0_rtx) :
- gen_rtx_EQ (VOIDmode, cc0_rtx, const0_rtx));
+ "switch (GET_CODE (operands[2]))
+ {
+ case GTU:
+ operands[4] = gen_rtx_NE (VOIDmode, cc0_rtx, const0_rtx);
+ break;
+ case LEU:
+ operands[4] = gen_rtx_EQ (VOIDmode, cc0_rtx, const0_rtx);
+ break;
+ default:
+ operands[4] = operands[2];
+ break;
+ }
operands[5] = GEN_INT (exact_log2 (INTVAL (operands[1]) + 1));")
;; Transform
@@ -4112,11 +4121,11 @@
;; dead 0xffffff?? except -1 and -2 eq/ne xor.b and not.l
;; dead 0xffff??ff eq/ne xor.b and not.l
;;
-;; live 1 geu/ltu copy and shlr.l
-;; live 3 (H8S) geu/ltu copy and shlr.l
+;; live 1 geu/ltu copy and shar.l
+;; live 3 (H8S) geu/ltu copy and shar.l
;;
-;; dead 1 geu/ltu shlr.l
-;; dead 3 (H8S) geu/ltu shlr.l
+;; dead 1 geu/ltu shar.l
+;; dead 3 (H8S) geu/ltu shar.l
;;
;; dead 3 (H8/300H) geu/ltu and.b and test
;; dead 7 geu/ltu and.b and test
@@ -4247,27 +4256,31 @@
;; into
;;
;; mov.l er0,er1
-;; shlr.l er1
+;; shar.l er1
;; bne .L1
+;; We avoid this transformation if we see more than one copy of the
+;; same compare insn immediately before this one.
+
(define_peephole2
[(match_scratch:SI 4 "r")
(set (cc0)
(compare (match_operand:SI 0 "register_operand" "")
(match_operand:SI 1 "const_int_operand" "")))
(set (pc)
- (if_then_else (match_operator 2 "gtuleu_operator"
+ (if_then_else (match_operator 2 "gtle_operator"
[(cc0) (const_int 0)])
(label_ref (match_operand 3 "" ""))
(pc)))]
"(TARGET_H8300H || TARGET_H8300S)
&& !peep2_reg_dead_p (1, operands[0])
&& (INTVAL (operands[1]) == 1
- || (TARGET_H8300S && INTVAL (operands[1]) == 3))"
+ || (TARGET_H8300S && INTVAL (operands[1]) == 3))
+ && !same_cmp_preceding_p (insn)"
[(set (match_dup 4)
(match_dup 0))
(parallel [(set (match_dup 4)
- (lshiftrt:SI (match_dup 4)
+ (ashiftrt:SI (match_dup 4)
(match_dup 6)))
(clobber (scratch:QI))])
(set (cc0)
@@ -4276,9 +4289,18 @@
(if_then_else (match_dup 5)
(label_ref (match_dup 3))
(pc)))]
- "operands[5] = ((GET_CODE (operands[2]) == GTU) ?
- gen_rtx_NE (VOIDmode, cc0_rtx, const0_rtx) :
- gen_rtx_EQ (VOIDmode, cc0_rtx, const0_rtx));
+ "switch (GET_CODE (operands[2]))
+ {
+ case GTU:
+ operands[5] = gen_rtx_NE (VOIDmode, cc0_rtx, const0_rtx);
+ break;
+ case LEU:
+ operands[5] = gen_rtx_EQ (VOIDmode, cc0_rtx, const0_rtx);
+ break;
+ default:
+ operands[5] = operands[2];
+ break;
+ }
operands[6] = GEN_INT (exact_log2 (INTVAL (operands[1]) + 1));")
;; Transform
@@ -4288,7 +4310,7 @@
;;
;; into
;;
-;; shlr.l er0
+;; shar.l er0
;; bne .L1
(define_peephole2
@@ -4296,7 +4318,7 @@
(compare (match_operand:SI 0 "register_operand" "")
(match_operand:SI 1 "const_int_operand" "")))
(set (pc)
- (if_then_else (match_operator 2 "gtuleu_operator"
+ (if_then_else (match_operator 2 "gtle_operator"
[(cc0) (const_int 0)])
(label_ref (match_operand 3 "" ""))
(pc)))]
@@ -4305,7 +4327,7 @@
&& (INTVAL (operands[1]) == 1
|| (TARGET_H8300S && INTVAL (operands[1]) == 3))"
[(parallel [(set (match_dup 0)
- (lshiftrt:SI (match_dup 0)
+ (ashiftrt:SI (match_dup 0)
(match_dup 5)))
(clobber (scratch:QI))])
(set (cc0)
@@ -4314,9 +4336,18 @@
(if_then_else (match_dup 4)
(label_ref (match_dup 3))
(pc)))]
- "operands[4] = ((GET_CODE (operands[2]) == GTU) ?
- gen_rtx_NE (VOIDmode, cc0_rtx, const0_rtx) :
- gen_rtx_EQ (VOIDmode, cc0_rtx, const0_rtx));
+ "switch (GET_CODE (operands[2]))
+ {
+ case GTU:
+ operands[4] = gen_rtx_NE (VOIDmode, cc0_rtx, const0_rtx);
+ break;
+ case LEU:
+ operands[4] = gen_rtx_EQ (VOIDmode, cc0_rtx, const0_rtx);
+ break;
+ default:
+ operands[4] = operands[2];
+ break;
+ }
operands[5] = GEN_INT (exact_log2 (INTVAL (operands[1]) + 1));")
;; Transform