This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch] h8300.md: Add a new peephole2.
- From: Kazu Hirata <kazu at cs dot umass dot edu>
- To: gcc-patches at gcc dot gnu dot org
- Date: Thu, 06 Mar 2003 10:14:51 -0500 (EST)
- Subject: [patch] h8300.md: Add a new peephole2.
Hi,
Attached is a patch to add a new peephole2.
Most H8's have 16-bit word access to memory. If a 32-bit load from
memory is followed by an AND that clears the upper half, we can narrow
the load from memory, saving 2 bytes and memory access time. In terms
assembly code,
mov.l @(28,er7),er0
and.l #28,er0
becomes
mov.w @(30,er7),r0
and.l #28,er0
Tested on h8300 port. Committed.
Kazu Hirata
2003-03-06 Kazu Hirata <kazu at cs dot umass dot edu>
* config/h8300/h8300.md (a new peephole2): New.
Index: h8300.md
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/h8300/h8300.md,v
retrieving revision 1.188
diff -u -r1.188 h8300.md
--- h8300.md 6 Mar 2003 01:34:55 -0000 1.188
+++ h8300.md 6 Mar 2003 12:45:43 -0000
@@ -3584,6 +3584,25 @@
"operands[2] = gen_lowpart (QImode, operands[0]);
operands[3] = gen_lowpart (QImode, operands[1]);")
+(define_peephole2
+ [(set (match_operand:SI 0 "register_operand" "")
+ (match_operand:SI 1 "memory_operand" ""))
+ (set (match_dup 0)
+ (and:SI (match_dup 0)
+ (match_operand:SI 2 "const_int_operand" "")))]
+ "(TARGET_H8300H || TARGET_H8300S)
+ && !reg_overlap_mentioned_p (operands[0], operands[1])
+ && !(GET_CODE (operands[1]) == MEM && MEM_VOLATILE_P (operands[1]))
+ && (INTVAL (operands[2]) & ~0xffff) == 0
+ && INTVAL (operands[2]) != 255"
+ [(set (match_dup 3)
+ (match_dup 4))
+ (set (match_dup 0)
+ (and:SI (match_dup 0)
+ (match_dup 2)))]
+ "operands[3] = gen_lowpart (HImode, operands[0]);
+ operands[4] = gen_lowpart (HImode, operands[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.