This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch] h8300.md: Fix the failure of 20020904-1.c.
- From: Kazu Hirata <kazu at cs dot umass dot edu>
- To: gcc-patches at gcc dot gnu dot org
- Date: Sat, 07 Sep 2002 16:21:28 -0400 (EDT)
- Subject: [patch] h8300.md: Fix the failure of 20020904-1.c.
Hi,
Attached is a patch to fix the failure of 20020904-1.c on the h8300
port.
In udivmodqi4, the dividend is taken in HImode. Thus "(uchar) 255" is
taken as -1 in HImode.
The patch addresses this problem by splitting the udivmodqi4 pattern
into an expander and an anonymous pattern. The expander zeroes out
the upper half of the dividend. The anonymous pattern is the same as
the original udivmodqi4 except that it is now anonymous.
The same applies to udivmodhi4.
Tested on the h8300 port. Committed.
Kazu Hirata
2002-09-07 Kazu Hirata <kazu@cs.umass.edu>
* config/h8300/h8300.md (udivmodqi4): Split the pattern into
an expander and an anonymous pattern. Zero out the upper half
of the dividend in the expander.
(udivmodqi4): Likewise.
Index: h8300.md
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/h8300/h8300.md,v
retrieving revision 1.89
diff -c -r1.89 h8300.md
*** h8300.md 7 Sep 2002 14:14:55 -0000 1.89
--- h8300.md 7 Sep 2002 19:57:50 -0000
***************
*** 911,917 ****
;; DIVIDE/MOD INSTRUCTIONS
;; ----------------------------------------------------------------------
! (define_insn "udivmodqi4"
[(set (match_operand:QI 0 "register_operand" "=r")
(truncate:QI
(udiv:HI
--- 911,935 ----
;; DIVIDE/MOD INSTRUCTIONS
;; ----------------------------------------------------------------------
! (define_expand "udivmodqi4"
! [(set (match_operand:HI 1 "register_operand" "")
! (and:HI (match_dup 1)
! (const_int 255)))
! (parallel [(set (match_operand:QI 0 "register_operand" "")
! (truncate:QI
! (udiv:HI
! (match_dup 1)
! (zero_extend:HI
! (match_operand:QI 2 "register_operand" "")))))
! (set (match_operand:QI 3 "register_operand" "")
! (truncate:QI
! (umod:HI
! (match_dup 1)
! (zero_extend:HI (match_dup 2)))))])]
! "TARGET_H8300H || TARGET_H8300S"
! "")
!
! (define_insn ""
[(set (match_operand:QI 0 "register_operand" "=r")
(truncate:QI
(udiv:HI
***************
*** 955,961 ****
[(set_attr "length" "6")
(set_attr "cc" "clobber")])
! (define_insn "udivmodhi4"
[(set (match_operand:HI 0 "register_operand" "=r")
(truncate:HI
(udiv:SI
--- 973,997 ----
[(set_attr "length" "6")
(set_attr "cc" "clobber")])
! (define_expand "udivmodhi4"
! [(set (match_operand:SI 1 "register_operand" "")
! (and:SI (match_dup 1)
! (const_int 65535)))
! (parallel [(set (match_operand:HI 0 "register_operand" "")
! (truncate:HI
! (udiv:SI
! (match_dup 1)
! (zero_extend:SI
! (match_operand:HI 2 "register_operand" "")))))
! (set (match_operand:HI 3 "register_operand" "")
! (truncate:HI
! (umod:SI
! (match_dup 1)
! (zero_extend:SI (match_dup 2)))))])]
! "TARGET_H8300H || TARGET_H8300S"
! "")
!
! (define_insn ""
[(set (match_operand:HI 0 "register_operand" "=r")
(truncate:HI
(udiv:SI