* config/h8300/h8300.md (a new peephole2): New.
authorKazu Hirata <kazu@cs.umass.edu>
Mon, 31 Mar 2003 10:18:29 +0000 (10:18 +0000)
committerKazu Hirata <kazu@gcc.gnu.org>
Mon, 31 Mar 2003 10:18:29 +0000 (10:18 +0000)
From-SVN: r65082

gcc/ChangeLog
gcc/config/h8300/h8300.md

index ebb5b7ef41a5a49659908db1c40fcc56d83e649e..fd3e32a6af914a2393558423e72ce0568a744874 100644 (file)
@@ -1,3 +1,7 @@
+2003-03-31  Kazu Hirata  <kazu@cs.umass.edu>
+
+       * config/h8300/h8300.md (a new peephole2): New.
+
 2003-03-31  Richard Sandiford  <rsandifo@redhat.com>
 
        * gcse.c (simple_mem): Return false for floating-point accesses
index b63ed49decc69601ef4988429bd1098ab5e231ac..f7170c969fa9cfb15531057a4f358dcbdde8b1cd 100644 (file)
   "operands[3] = gen_lowpart (HImode, operands[0]);
    operands[4] = gen_lowpart (HImode, operands[1]);")
 
+;; (compare (reg:HI) (const_int)) takes 4 bytes, so we try to achieve
+;; the equivalent with shorter sequences.  Here is the summary.  Cases
+;; are grouped for each define_peephole2.
+;;
+;; reg  const_int                   use     insn
+;; --------------------------------------------------------
+;; dead    -2                       eq/ne   inc.l
+;; dead    -1                       eq/ne   inc.l
+;; 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   255                       geu/ltu mov.b
+
+(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)
+                  (lshiftrt:HI (match_dup 0)
+                               (match_dup 5)))
+             (clobber (scratch:QI))])
+   (set (cc0)
+       (match_dup 0))
+   (set (pc)
+       (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));
+   operands[5] = GEN_INT (exact_log2 (INTVAL (operands[1]) + 1));")
+
 ;; (compare (reg:SI) (const_int)) takes 6 bytes, so we try to achieve
 ;; the equivalent with shorter sequences.  Here is the summary.  Cases
 ;; are grouped for each define_peephole2.