Commit 0e26895c by Kazu Hirata Committed by Kazu Hirata

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
parent 676e33ca
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> 2004-03-02 Zdenek Dvorak <rakdver@atrey.karlin.mff.cuni.cz>
* dominance.c (recount_dominator): Handle postdominators. * dominance.c (recount_dominator): Handle postdominators.
......
...@@ -1793,14 +1793,14 @@ eqne_operator (rtx x, enum machine_mode mode ATTRIBUTE_UNUSED) ...@@ -1793,14 +1793,14 @@ eqne_operator (rtx x, enum machine_mode mode ATTRIBUTE_UNUSED)
return (code == EQ || code == NE); 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 int
gtle_operator (rtx x, enum machine_mode mode ATTRIBUTE_UNUSED) gtle_operator (rtx x, enum machine_mode mode ATTRIBUTE_UNUSED)
{ {
enum rtx_code code = GET_CODE (x); 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. */ /* Return nonzero if X is either GTU or LEU. */
......
...@@ -4135,9 +4135,14 @@ ...@@ -4135,9 +4135,14 @@
;; dead 1 eq/ne dec.l ;; dead 1 eq/ne dec.l
;; dead 2 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 1 geu/ltu shar.l
;; dead 3 (H8S) geu/ltu shar.l ;; dead 3 (H8S) geu/ltu shar.l
;; ;;
;; ---- 255 ge/lt mov.b
;;
;; ---- 255 geu/ltu mov.b ;; ---- 255 geu/ltu mov.b
;; Transform ;; Transform
...@@ -4203,22 +4208,10 @@ ...@@ -4203,22 +4208,10 @@
(set (cc0) (set (cc0)
(match_dup 0)) (match_dup 0))
(set (pc) (set (pc)
(if_then_else (match_dup 5) (if_then_else (match_dup 2)
(label_ref (match_dup 3)) (label_ref (match_dup 3))
(pc)))] (pc)))]
"switch (GET_CODE (operands[2])) "operands[4] = GEN_INT (exact_log2 (INTVAL (operands[1]) + 1));")
{
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));")
;; Transform ;; Transform
;; ;;
...@@ -4230,7 +4223,36 @@ ...@@ -4230,7 +4223,36 @@
;; shar.w r0 ;; shar.w r0
;; bne .L1 ;; 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 ;; Transform
;; ;;
...@@ -4256,21 +4278,10 @@ ...@@ -4256,21 +4278,10 @@
(and:HI (match_dup 0) (and:HI (match_dup 0)
(const_int -256))) (const_int -256)))
(set (pc) (set (pc)
(if_then_else (match_dup 3) (if_then_else (match_dup 1)
(label_ref (match_dup 2)) (label_ref (match_dup 2))
(pc)))] (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 ;; Transform
;; ;;
...@@ -4282,7 +4293,29 @@ ...@@ -4282,7 +4293,29 @@
;; mov.b r0h,r0h ;; mov.b r0h,r0h
;; bne .L1 ;; 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 ;; (compare (reg:SI) (const_int)) takes 6 bytes, so we try to achieve
;; the equivalent with shorter sequences. Here is the summary. Cases ;; the equivalent with shorter sequences. Here is the summary. Cases
...@@ -4314,12 +4347,26 @@ ...@@ -4314,12 +4347,26 @@
;; dead 0x40000000 (H8S) eq/ne rotl.l and dec.l ;; dead 0x40000000 (H8S) eq/ne rotl.l and dec.l
;; dead 0x80000000 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 1 geu/ltu copy and shar.l
;; live 3 (H8S) 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 1 geu/ltu shar.l
;; dead 3 (H8S) 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 3 (H8/300H) geu/ltu and.b and test
;; dead 7 geu/ltu and.b and test ;; dead 7 geu/ltu and.b and test
;; dead 15 geu/ltu and.b and test ;; dead 15 geu/ltu and.b and test
...@@ -4328,6 +4375,8 @@ ...@@ -4328,6 +4375,8 @@
;; dead 127 geu/ltu and.b and test ;; dead 127 geu/ltu and.b and test
;; dead 255 geu/ltu and.b and test ;; dead 255 geu/ltu and.b and test
;; ;;
;; ---- 65535 ge/lt mov.w
;;
;; ---- 65535 geu/ltu mov.w ;; ---- 65535 geu/ltu mov.w
;; For a small constant, it is cheaper to actually do the subtraction ;; For a small constant, it is cheaper to actually do the subtraction
...@@ -4507,22 +4556,10 @@ ...@@ -4507,22 +4556,10 @@
(set (cc0) (set (cc0)
(match_dup 4)) (match_dup 4))
(set (pc) (set (pc)
(if_then_else (match_dup 6) (if_then_else (match_dup 2)
(label_ref (match_dup 3)) (label_ref (match_dup 3))
(pc)))] (pc)))]
"switch (GET_CODE (operands[2])) "operands[5] = GEN_INT (exact_log2 (INTVAL (operands[1]) + 1));")
{
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));")
;; Transform ;; Transform
;; ;;
...@@ -4535,7 +4572,43 @@ ...@@ -4535,7 +4572,43 @@
;; shar.l er1 ;; shar.l er1
;; bne .L1 ;; 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 ;; Transform
;; ;;
...@@ -4567,22 +4640,10 @@ ...@@ -4567,22 +4640,10 @@
(set (cc0) (set (cc0)
(match_dup 0)) (match_dup 0))
(set (pc) (set (pc)
(if_then_else (match_dup 5) (if_then_else (match_dup 2)
(label_ref (match_dup 3)) (label_ref (match_dup 3))
(pc)))] (pc)))]
"switch (GET_CODE (operands[2])) "operands[4] = GEN_INT (exact_log2 (INTVAL (operands[1]) + 1));")
{
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));")
;; Transform ;; Transform
;; ;;
...@@ -4594,7 +4655,36 @@ ...@@ -4594,7 +4655,36 @@
;; shar.l er0 ;; shar.l er0
;; bne .L1 ;; 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 ;; Transform
;; ;;
...@@ -4631,22 +4721,10 @@ ...@@ -4631,22 +4721,10 @@
(set (cc0) (set (cc0)
(match_dup 0)) (match_dup 0))
(set (pc) (set (pc)
(if_then_else (match_dup 5) (if_then_else (match_dup 2)
(label_ref (match_dup 3)) (label_ref (match_dup 3))
(pc)))] (pc)))]
"switch (GET_CODE (operands[2])) "operands[4] = GEN_INT (~INTVAL (operands[1]));")
{
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]));")
;; Transform ;; Transform
;; ;;
...@@ -4659,7 +4737,40 @@ ...@@ -4659,7 +4737,40 @@
;; mov.l er0,er0 ;; mov.l er0,er0
;; bne .L1 ;; 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 ;; Transform
;; ;;
...@@ -4685,21 +4796,10 @@ ...@@ -4685,21 +4796,10 @@
(and:SI (match_dup 0) (and:SI (match_dup 0)
(const_int -65536))) (const_int -65536)))
(set (pc) (set (pc)
(if_then_else (match_dup 3) (if_then_else (match_dup 1)
(label_ref (match_dup 2)) (label_ref (match_dup 2))
(pc)))] (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 ;; Transform
;; ;;
...@@ -4711,7 +4811,29 @@ ...@@ -4711,7 +4811,29 @@
;; mov.l e0,e0 ;; mov.l e0,e0
;; bne .L1 ;; 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 ;; 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 ;; of the register being tested, do the subtraction on the copy, and
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment