aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKazu Hirata <kazu@cs.umass.edu>2002-12-29 14:36:35 +0000
committerKazu Hirata <kazu@gcc.gnu.org>2002-12-29 14:36:35 +0000
commit2873836bd934145499b517508acf2efb0e0857f9 (patch)
treeeb9c2855ec2d99ea5f3e78307fe8a6dd97724558
parentb63d28bf68c4c23e55a596371103cd55c560f13c (diff)
downloadgcc-2873836bd934145499b517508acf2efb0e0857f9.zip
gcc-2873836bd934145499b517508acf2efb0e0857f9.tar.gz
gcc-2873836bd934145499b517508acf2efb0e0857f9.tar.bz2
h8300-protos.h: Add prototypes for const_int_qi_operand and const_int_hi_operand.
* config/h8300/h8300-protos.h: Add prototypes for const_int_qi_operand and const_int_hi_operand. * config/h8300/h8300.c (const_int_qi_operand): New. (const_int_hi_operand): Likewise. * config/h8300/h8300.md (three peepholes): New. From-SVN: r60600
-rw-r--r--gcc/ChangeLog8
-rw-r--r--gcc/config/h8300/h8300-protos.h2
-rw-r--r--gcc/config/h8300/h8300.c22
-rw-r--r--gcc/config/h8300/h8300.md74
4 files changed, 106 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 0693b60..52660f7 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,11 @@
+2002-12-29 Kazu Hirata <kazu@cs.umass.edu>
+
+ * config/h8300/h8300-protos.h: Add prototypes for
+ const_int_qi_operand and const_int_hi_operand.
+ * config/h8300/h8300.c (const_int_qi_operand): New.
+ (const_int_hi_operand): Likewise.
+ * config/h8300/h8300.md (three peepholes): New.
+
2002-12-28 Joseph S. Myers <jsm@polyomino.org.uk>
* doc/cpp.texi, doc/gcc.texi, doc/gccint.texi, doc/install.texi:
diff --git a/gcc/config/h8300/h8300-protos.h b/gcc/config/h8300/h8300-protos.h
index 9f52ea5..e18dc24 100644
--- a/gcc/config/h8300/h8300-protos.h
+++ b/gcc/config/h8300/h8300-protos.h
@@ -64,6 +64,8 @@ extern int bit_operand PARAMS ((rtx, enum machine_mode));
extern int bit_memory_operand PARAMS ((rtx, enum machine_mode));
extern int const_le_2_operand PARAMS ((rtx, enum machine_mode));
extern int const_le_6_operand PARAMS ((rtx, enum machine_mode));
+extern int const_int_qi_operand PARAMS ((rtx, enum machine_mode));
+extern int const_int_hi_operand PARAMS ((rtx, enum machine_mode));
extern int incdec_operand PARAMS ((rtx, enum machine_mode));
extern int bit_operator PARAMS ((rtx, enum machine_mode));
extern int nshift_operator PARAMS ((rtx, enum machine_mode));
diff --git a/gcc/config/h8300/h8300.c b/gcc/config/h8300/h8300.c
index b32f9c3..afa43c1 100644
--- a/gcc/config/h8300/h8300.c
+++ b/gcc/config/h8300/h8300.c
@@ -1851,6 +1851,28 @@ const_le_6_operand (x, mode)
&& abs (INTVAL (x)) <= 6);
}
+/* Return nonzero if X is a constant expressible in QImode. */
+
+int
+const_int_qi_operand (x, mode)
+ rtx x;
+ enum machine_mode mode ATTRIBUTE_UNUSED;
+{
+ return (GET_CODE (x) == CONST_INT
+ && (INTVAL (x) & 0xff) == INTVAL (x));
+}
+
+/* Return nonzero if X is a constant expressible in HImode. */
+
+int
+const_int_hi_operand (x, mode)
+ rtx x;
+ enum machine_mode mode ATTRIBUTE_UNUSED;
+{
+ return (GET_CODE (x) == CONST_INT
+ && (INTVAL (x) & 0xffff) == INTVAL (x));
+}
+
/* Return nonzero if X is a constant suitable for inc/dec. */
int
diff --git a/gcc/config/h8300/h8300.md b/gcc/config/h8300/h8300.md
index fd41ad3..b377961 100644
--- a/gcc/config/h8300/h8300.md
+++ b/gcc/config/h8300/h8300.md
@@ -2962,3 +2962,77 @@
(pc)))]
"operands[1] = GEN_INT (- INTVAL (operands[1]));
split_adds_subs (SImode, operands, 1);")
+
+;; Narrow the mode of testing if possible.
+
+(define_peephole2
+ [(set (match_operand:HI 0 "register_operand" "")
+ (and:HI (match_dup 0)
+ (match_operand:HI 1 "const_int_qi_operand" "")))
+ (set (cc0)
+ (match_dup 0))
+ (set (pc)
+ (if_then_else (match_operator 3 "eqne_operator"
+ [(cc0) (const_int 0)])
+ (label_ref (match_operand 2 "" ""))
+ (pc)))]
+ "find_regno_note (next_nonnote_insn (insn), REG_DEAD, REGNO (operands[0]))"
+ [(set (match_dup 4)
+ (and:QI (match_dup 4)
+ (match_dup 5)))
+ (set (cc0)
+ (match_dup 4))
+ (set (pc)
+ (if_then_else (match_op_dup 3 [(cc0) (const_int 0)])
+ (label_ref (match_dup 2))
+ (pc)))]
+ "operands[4] = gen_rtx_REG (QImode, REGNO (operands[0]));
+ operands[5] = GEN_INT (trunc_int_for_mode (INTVAL (operands[1]), QImode));")
+
+(define_peephole2
+ [(set (match_operand:SI 0 "register_operand" "")
+ (and:SI (match_dup 0)
+ (match_operand:SI 1 "const_int_qi_operand" "")))
+ (set (cc0)
+ (match_dup 0))
+ (set (pc)
+ (if_then_else (match_operator 3 "eqne_operator"
+ [(cc0) (const_int 0)])
+ (label_ref (match_operand 2 "" ""))
+ (pc)))]
+ "find_regno_note (next_nonnote_insn (insn), REG_DEAD, REGNO (operands[0]))"
+ [(set (match_dup 4)
+ (and:QI (match_dup 4)
+ (match_dup 5)))
+ (set (cc0)
+ (match_dup 4))
+ (set (pc)
+ (if_then_else (match_op_dup 3 [(cc0) (const_int 0)])
+ (label_ref (match_dup 2))
+ (pc)))]
+ "operands[4] = gen_rtx_REG (QImode, REGNO (operands[0]));
+ operands[5] = GEN_INT (trunc_int_for_mode (INTVAL (operands[1]), QImode));")
+
+(define_peephole2
+ [(set (match_operand:SI 0 "register_operand" "")
+ (and:SI (match_dup 0)
+ (match_operand:SI 1 "const_int_hi_operand" "")))
+ (set (cc0)
+ (match_dup 0))
+ (set (pc)
+ (if_then_else (match_operator 3 "eqne_operator"
+ [(cc0) (const_int 0)])
+ (label_ref (match_operand 2 "" ""))
+ (pc)))]
+ "find_regno_note (next_nonnote_insn (insn), REG_DEAD, REGNO (operands[0]))"
+ [(set (match_dup 4)
+ (and:HI (match_dup 4)
+ (match_dup 5)))
+ (set (cc0)
+ (match_dup 4))
+ (set (pc)
+ (if_then_else (match_op_dup 3 [(cc0) (const_int 0)])
+ (label_ref (match_dup 2))
+ (pc)))]
+ "operands[4] = gen_rtx_REG (HImode, REGNO (operands[0]));
+ operands[5] = GEN_INT (trunc_int_for_mode (INTVAL (operands[1]), HImode));")