This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: mips16: div/mod by zero patch
- To: Gavin Koch <gavin at cygnus dot com>
- Subject: Re: mips16: div/mod by zero patch
- From: Jeffrey A Law <law at unknown>
- Date: Mon, 19 Jan 1998 14:31:22 -0700
- cc: egcs at cygnus dot com
- Reply-To: law at cygnus dot com
In message <m0xsbHR-0006vBC@cetus.cygnus.com>you write:
>
> In the mips backend, for non-optimized -mips16 code, for a div
> or mod by the constant zero (or something that folds to the
> constant zero), the compiler is generating something like
>
> div $0,$4,0
>
> which is not a valid mips16 instruction, and you get assembler
> errors.
>
> (Of course div or mod by zero will fail, but it should not
> do so until runtime, if the expression is exectuted. Ironically
> this does not fail for other constants, because the compiler
> generally generates a sequence of shifts and adds for the division.)
>
> This patch fixes this by changing the non-optimized div and mod
> insns to force the last arg into a register if -mips16.
>
> mips/mips.md (divsi3,divdi3,modsi3,moddi3,udivsi3,udivdi3,
> umodsi3,umoddi3): Handle mips16 div/mod by a constant.
Looks reasonable to me. I think you should install this patch.
jeff