This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] h8300.md: Generalize a peephole2.


Hi,

Attached is a patch to generalize a peephole2.

The generalized peephole2 transforms

	mov.l	@(32,er7),er2 ; Read a 32-bit word from memory
	and	#0,r2h        ; AND with 0x000000ff
	sub.w	e2,e2

into

	sub.l	er2,er2       ; Clear the destination
	mov.b	@(35,er7),r2l ; Read a byte from memory

Tested on h8300 port.  Committed.

Kazu Hirata

2003-03-05  Kazu Hirata  <kazu at cs dot umass dot edu>

	* config/h8300/h8300.md (a peephole2): Generalize to
	accept a memory operand.

Index: h8300.md
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/h8300/h8300.md,v
retrieving revision 1.187
diff -c -r1.187 h8300.md
*** h8300.md	5 Mar 2003 22:10:52 -0000	1.187
--- h8300.md	5 Mar 2003 22:30:52 -0000
***************
*** 3570,3589 ****
  
  (define_peephole2
    [(set (match_operand:SI 0 "register_operand" "")
! 	(match_operand:SI 1 "register_operand" ""))
     (set (match_dup 0)
  	(and:SI (match_dup 0)
  		(const_int 255)))]
    "(TARGET_H8300H || TARGET_H8300S)
!    && REG_P (operands[0])
!    && REG_P (operands[1])
!    && REGNO (operands[0]) != REGNO (operands[1])"
    [(set (match_dup 0)
  	(const_int 0))
     (set (strict_low_part (match_dup 2))
  	(match_dup 3))]
!   "operands[2] = gen_rtx_REG (QImode, REGNO (operands[0]));
!    operands[3] = gen_rtx_REG (QImode, REGNO (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
--- 3570,3588 ----
  
  (define_peephole2
    [(set (match_operand:SI 0 "register_operand" "")
! 	(match_operand:SI 1 "general_operand" ""))
     (set (match_dup 0)
  	(and:SI (match_dup 0)
  		(const_int 255)))]
    "(TARGET_H8300H || TARGET_H8300S)
!    && !reg_overlap_mentioned_p (operands[0], operands[1])
!    && !(GET_CODE (operands[1]) == MEM && MEM_VOLATILE_P (operands[1]))"
    [(set (match_dup 0)
  	(const_int 0))
     (set (strict_low_part (match_dup 2))
  	(match_dup 3))]
!   "operands[2] = gen_lowpart (QImode, operands[0]);
!    operands[3] = gen_lowpart (QImode, 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]