This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: divmod , signed division problem in rtl
- From: Momchil Velikov <velco at fadata dot bg>
- To: Pierre Mallard <pierremallard at yahoo dot fr>
- Cc: gcc at gcc dot gnu dot org
- Date: 09 Oct 2002 20:56:02 +0300
- Subject: Re: divmod , signed division problem in rtl
- References: <20021009134151.67778.qmail@web20309.mail.yahoo.com>
>>>>> "Pierre" == Pierre Mallard <pierremallard@yahoo.fr> writes:
Pierre> Hi,
Pierre> My Proc got a divss op I'd like to put in gcc.
Pierre> For me it's relative to QI regs so I thought first
Pierre> It's fine if I define :
Pierre> (define_insn "divmodqi4"
Pierre> [(set (match_operand:QI 0 "register_operand" "=r")
Pierre> (div:QI (match_operand:QI 1 "register_operand"
Pierre> "r")
Pierre> (match_operand:QI 2 "register_operand"
Pierre> "r")))
Pierre> (set (match_operand:QI 3 "register_operand" "=r")
Pierre> (mod:QI (match_dup 1) (match_dup 2)))]
Pierre> ""
Pierre> "nop
Pierre> divss __tmp_l__,%1,%2
Pierre> mov %0,__tmp_l__
Pierre> mov %3,__tmp_h__"
Pierre> [(set_attr "length" "4")
Pierre> (set_attr "cc" "none")])
Pierre> Unfortunately, this doesn't seem to work.
Pierre> For a signed division in QImode, the rtl gen passes
Pierre> will automaticly looks for the divmodhi4 pattern and
Pierre> will want to sign_extend the result in HI where it's
Pierre> only needed in QI..
Pierre> Can someone tell me why ?
Because of the integer promotions, the abstract C machine should
perform the divmod operation in SImode. The compiler can perform the
computation in shorter mode only if the result is representable in
that shorter mode, which is not the case with signed QImode division
(e.g. SCHAR_MIN / -1), unlike the case with unsigned division.
OTOH, HImode can represent the result of QImode operations, so it is
used.
Similarly, HImode signed division is perfomed in SImode, but the
unsigned division can be performed in HImode.
~velco