aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorKazu Hirata <kazu@cs.umass.edu>2004-03-02 02:20:21 +0000
committerKazu Hirata <kazu@gcc.gnu.org>2004-03-02 02:20:21 +0000
commit0e26895cf293d1772713d09fe0ca660bfc3ec3db (patch)
tree2072c8d226142e670166371bad8b608ec3f3bf83 /gcc
parent676e33ca810aa9f33fd233c75d845638e4755c0d (diff)
downloadgcc-0e26895cf293d1772713d09fe0ca660bfc3ec3db.zip
gcc-0e26895cf293d1772713d09fe0ca660bfc3ec3db.tar.gz
gcc-0e26895cf293d1772713d09fe0ca660bfc3ec3db.tar.bz2
h8300.c (gtle_operator): Accept GT and LE.
* config/h8300/h8300.c (gtle_operator): Accept GT and LE. * config/h8300/h8300.md: Split several peephole2's, each into two. From-SVN: r78741
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/config/h8300/h8300.c4
-rw-r--r--gcc/config/h8300/h8300.md298
3 files changed, 218 insertions, 90 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 3661aa88..62719ce 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2004-03-01 Kazu Hirata <kazu@cs.umass.edu>
+
+ * config/h8300/h8300.c (gtle_operator): Accept GT and LE.
+ * config/h8300/h8300.md: Split several peephole2's, each into
+ two.
+
2004-03-02 Zdenek Dvorak <rakdver@atrey.karlin.mff.cuni.cz>
* dominance.c (recount_dominator): Handle postdominators.
diff --git a/gcc/config/h8300/h8300.c b/gcc/config/h8300/h8300.c
index ad50955..11e675c 100644
--- a/gcc/config/h8300/h8300.c
+++ b/gcc/config/h8300/h8300.c
@@ -1793,14 +1793,14 @@ eqne_operator (rtx x, enum machine_mode mode ATTRIBUTE_UNUSED)
return (code == EQ || code == NE);
}
-/* Return nonzero if X is GT, LE, GTU, or LEU. */
+/* Return nonzero if X is either GT or LE. */
int
gtle_operator (rtx x, enum machine_mode mode ATTRIBUTE_UNUSED)
{
enum rtx_code code = GET_CODE (x);
- return (code == GT || code == LE || code == GTU || code == LEU);
+ return (code == GT || code == LE);
}
/* Return nonzero if X is either GTU or LEU. */
diff --git a/gcc/config/h8300/h8300.md b/gcc/config/h8300/h8300.md
index eede391..18995e7 100644
--- a/gcc/config/h8300/h8300.md
+++ b/gcc/config/h8300/h8300.md
@@ -4135,9 +4135,14 @@
;; dead 1 eq/ne dec.l
;; dead 2 eq/ne dec.l
;;
+;; dead 1 ge/lt shar.l
+;; dead 3 (H8S) ge/lt shar.l
+;;
;; dead 1 geu/ltu shar.l
;; dead 3 (H8S) geu/ltu shar.l
;;
+;; ---- 255 ge/lt mov.b
+;;
;; ---- 255 geu/ltu mov.b
;; Transform
@@ -4203,22 +4208,10 @@
(set (cc0)
(match_dup 0))
(set (pc)
- (if_then_else (match_dup 5)
+ (if_then_else (match_dup 2)
(label_ref (match_dup 3))
(pc)))]
- "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[4] = GEN_INT (exact_log2 (INTVAL (operands[1]) + 1));")
+ "operands[4] = GEN_INT (exact_log2 (INTVAL (operands[1]) + 1));")
;; Transform
;;
@@ -4230,7 +4223,36 @@
;; shar.w r0
;; bne .L1
-;; TODO: Split the above peephole2.
+(define_peephole2
+ [(set (cc0)
+ (compare (match_operand:HI 0 "register_operand" "")
+ (match_operand:HI 1 "const_int_operand" "")))
+ (set (pc)
+ (if_then_else (match_operator 2 "gtuleu_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))"
+ [(parallel [(set (match_dup 0)
+ (ashiftrt:HI (match_dup 0)
+ (match_dup 4)))
+ (clobber (scratch:QI))])
+ (set (cc0)
+ (match_dup 0))
+ (set (pc)
+ (if_then_else (match_dup 5)
+ (label_ref (match_dup 3))
+ (pc)))]
+{
+ operands[4] = GEN_INT (exact_log2 (INTVAL (operands[1]) + 1));
+ operands[5] = gen_rtx_fmt_ee (GET_CODE (operands[2]) == GTU ? NE : EQ,
+ VOIDmode,
+ cc0_rtx,
+ const0_rtx);
+})
;; Transform
;;
@@ -4256,21 +4278,10 @@
(and:HI (match_dup 0)
(const_int -256)))
(set (pc)
- (if_then_else (match_dup 3)
+ (if_then_else (match_dup 1)
(label_ref (match_dup 2))
(pc)))]
- "switch (GET_CODE (operands[1]))
- {
- case GTU:
- operands[3] = gen_rtx_NE (VOIDmode, cc0_rtx, const0_rtx);
- break;
- case LEU:
- operands[3] = gen_rtx_EQ (VOIDmode, cc0_rtx, const0_rtx);
- break;
- default:
- operands[3] = operands[1];
- break;
- }")
+ "")
;; Transform
;;
@@ -4282,7 +4293,29 @@
;; mov.b r0h,r0h
;; bne .L1
-;; TODO: Split the above peephole2.
+(define_peephole2
+ [(set (cc0)
+ (compare (match_operand:HI 0 "register_operand" "")
+ (const_int 255)))
+ (set (pc)
+ (if_then_else (match_operator 1 "gtuleu_operator"
+ [(cc0) (const_int 0)])
+ (label_ref (match_operand 2 "" ""))
+ (pc)))]
+ "TARGET_H8300H || TARGET_H8300S"
+ [(set (cc0)
+ (and:HI (match_dup 0)
+ (const_int -256)))
+ (set (pc)
+ (if_then_else (match_dup 3)
+ (label_ref (match_dup 2))
+ (pc)))]
+{
+ operands[3] = gen_rtx_fmt_ee (GET_CODE (operands[1]) == GTU ? NE : EQ,
+ VOIDmode,
+ cc0_rtx,
+ const0_rtx);
+})
;; (compare (reg:SI) (const_int)) takes 6 bytes, so we try to achieve
;; the equivalent with shorter sequences. Here is the summary. Cases
@@ -4314,12 +4347,26 @@
;; dead 0x40000000 (H8S) eq/ne rotl.l and dec.l
;; dead 0x80000000 eq/ne rotl.l and dec.l
;;
+;; live 1 ge/lt copy and shar.l
+;; live 3 (H8S) ge/lt copy and shar.l
+;;
;; live 1 geu/ltu copy and shar.l
;; live 3 (H8S) geu/ltu copy and shar.l
;;
+;; dead 1 ge/lt shar.l
+;; dead 3 (H8S) ge/lt shar.l
+;;
;; dead 1 geu/ltu shar.l
;; dead 3 (H8S) geu/ltu shar.l
;;
+;; dead 3 (H8/300H) ge/lt and.b and test
+;; dead 7 ge/lt and.b and test
+;; dead 15 ge/lt and.b and test
+;; dead 31 ge/lt and.b and test
+;; dead 63 ge/lt and.b and test
+;; dead 127 ge/lt and.b and test
+;; dead 255 ge/lt and.b and test
+;;
;; dead 3 (H8/300H) geu/ltu and.b and test
;; dead 7 geu/ltu and.b and test
;; dead 15 geu/ltu and.b and test
@@ -4328,6 +4375,8 @@
;; dead 127 geu/ltu and.b and test
;; dead 255 geu/ltu and.b and test
;;
+;; ---- 65535 ge/lt mov.w
+;;
;; ---- 65535 geu/ltu mov.w
;; For a small constant, it is cheaper to actually do the subtraction
@@ -4507,22 +4556,10 @@
(set (cc0)
(match_dup 4))
(set (pc)
- (if_then_else (match_dup 6)
+ (if_then_else (match_dup 2)
(label_ref (match_dup 3))
(pc)))]
- "switch (GET_CODE (operands[2]))
- {
- case GTU:
- operands[6] = gen_rtx_NE (VOIDmode, cc0_rtx, const0_rtx);
- break;
- case LEU:
- operands[6] = gen_rtx_EQ (VOIDmode, cc0_rtx, const0_rtx);
- break;
- default:
- operands[6] = operands[2];
- break;
- }
- operands[5] = GEN_INT (exact_log2 (INTVAL (operands[1]) + 1));")
+ "operands[5] = GEN_INT (exact_log2 (INTVAL (operands[1]) + 1));")
;; Transform
;;
@@ -4535,7 +4572,43 @@
;; shar.l er1
;; bne .L1
-;; TODO: Split the above peephole2.
+;; 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"
+ [(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))
+ && !same_cmp_preceding_p (insn)"
+ [(set (match_dup 4)
+ (match_dup 0))
+ (parallel [(set (match_dup 4)
+ (ashiftrt:SI (match_dup 4)
+ (match_dup 5)))
+ (clobber (scratch:QI))])
+ (set (cc0)
+ (match_dup 4))
+ (set (pc)
+ (if_then_else (match_dup 6)
+ (label_ref (match_dup 3))
+ (pc)))]
+{
+ operands[5] = GEN_INT (exact_log2 (INTVAL (operands[1]) + 1));
+ operands[6] = gen_rtx_fmt_ee (GET_CODE (operands[2]) == GTU ? NE : EQ,
+ VOIDmode,
+ cc0_rtx,
+ const0_rtx);
+})
;; Transform
;;
@@ -4567,22 +4640,10 @@
(set (cc0)
(match_dup 0))
(set (pc)
- (if_then_else (match_dup 5)
+ (if_then_else (match_dup 2)
(label_ref (match_dup 3))
(pc)))]
- "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[4] = GEN_INT (exact_log2 (INTVAL (operands[1]) + 1));")
+ "operands[4] = GEN_INT (exact_log2 (INTVAL (operands[1]) + 1));")
;; Transform
;;
@@ -4594,7 +4655,36 @@
;; shar.l er0
;; bne .L1
-;; TODO: Split the above peephole2.
+(define_peephole2
+ [(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"
+ [(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))"
+ [(parallel [(set (match_dup 0)
+ (ashiftrt:SI (match_dup 0)
+ (match_dup 4)))
+ (clobber (scratch:QI))])
+ (set (cc0)
+ (match_dup 0))
+ (set (pc)
+ (if_then_else (match_dup 5)
+ (label_ref (match_dup 3))
+ (pc)))]
+{
+ operands[4] = GEN_INT (exact_log2 (INTVAL (operands[1]) + 1));
+ operands[5] = gen_rtx_fmt_ee (GET_CODE (operands[2]) == GTU ? NE : EQ,
+ VOIDmode,
+ cc0_rtx,
+ const0_rtx);
+})
;; Transform
;;
@@ -4631,22 +4721,10 @@
(set (cc0)
(match_dup 0))
(set (pc)
- (if_then_else (match_dup 5)
+ (if_then_else (match_dup 2)
(label_ref (match_dup 3))
(pc)))]
- "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[4] = GEN_INT (~INTVAL (operands[1]));")
+ "operands[4] = GEN_INT (~INTVAL (operands[1]));")
;; Transform
;;
@@ -4659,7 +4737,40 @@
;; mov.l er0,er0
;; bne .L1
-;; TODO: Split the above peephole2.
+(define_peephole2
+ [(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"
+ [(cc0) (const_int 0)])
+ (label_ref (match_operand 3 "" ""))
+ (pc)))]
+ "(TARGET_H8300H || TARGET_H8300S)
+ && peep2_reg_dead_p (1, operands[0])
+ && ((TARGET_H8300H && INTVAL (operands[1]) == 3)
+ || INTVAL (operands[1]) == 7
+ || INTVAL (operands[1]) == 15
+ || INTVAL (operands[1]) == 31
+ || INTVAL (operands[1]) == 63
+ || INTVAL (operands[1]) == 127
+ || INTVAL (operands[1]) == 255)"
+ [(set (match_dup 0)
+ (and:SI (match_dup 0)
+ (match_dup 4)))
+ (set (cc0)
+ (match_dup 0))
+ (set (pc)
+ (if_then_else (match_dup 5)
+ (label_ref (match_dup 3))
+ (pc)))]
+{
+ operands[4] = GEN_INT (~INTVAL (operands[1]));
+ operands[5] = gen_rtx_fmt_ee (GET_CODE (operands[2]) == GTU ? NE : EQ,
+ VOIDmode,
+ cc0_rtx,
+ const0_rtx);
+})
;; Transform
;;
@@ -4685,21 +4796,10 @@
(and:SI (match_dup 0)
(const_int -65536)))
(set (pc)
- (if_then_else (match_dup 3)
+ (if_then_else (match_dup 1)
(label_ref (match_dup 2))
(pc)))]
- "switch (GET_CODE (operands[1]))
- {
- case GTU:
- operands[3] = gen_rtx_NE (VOIDmode, cc0_rtx, const0_rtx);
- break;
- case LEU:
- operands[3] = gen_rtx_EQ (VOIDmode, cc0_rtx, const0_rtx);
- break;
- default:
- operands[3] = operands[1];
- break;
- }")
+ "")
;; Transform
;;
@@ -4711,7 +4811,29 @@
;; mov.l e0,e0
;; bne .L1
-;; TODO: Split the above peephole2.
+(define_peephole2
+ [(set (cc0)
+ (compare (match_operand:SI 0 "register_operand" "")
+ (const_int 65535)))
+ (set (pc)
+ (if_then_else (match_operator 1 "gtuleu_operator"
+ [(cc0) (const_int 0)])
+ (label_ref (match_operand 2 "" ""))
+ (pc)))]
+ "TARGET_H8300H || TARGET_H8300S"
+ [(set (cc0)
+ (and:SI (match_dup 0)
+ (const_int -65536)))
+ (set (pc)
+ (if_then_else (match_dup 3)
+ (label_ref (match_dup 2))
+ (pc)))]
+{
+ operands[3] = gen_rtx_fmt_ee (GET_CODE (operands[1]) == GTU ? NE : EQ,
+ VOIDmode,
+ cc0_rtx,
+ const0_rtx);
+})
;; For constants like -1, -2, 1, 2, it is still cheaper to make a copy
;; of the register being tested, do the subtraction on the copy, and