[M3devel] how division and modulo work in hand.c?

Tony Hosking hosking at cs.purdue.edu
Mon Jan 18 14:47:41 CET 2010


cm3cg currently only uses FLOOR_DIV_EXPR for known positive integers.  For anything else it calls out to the library.

On 17 Jan 2010, at 20:06, Jay K wrote:

> I *speculate*:
>    If the inputs to div or mod are known to have the same sign: don't bother calling the functions.
>       Certainly that is clear for two positive inputs in the old functions.
>    If either input to div is known to be zero, ditto. Presumably not a common case.
>       And *maybe* we want to alter how divide by zero works to reliably trap or not trap.
>  
>   For example, CARDINAL and LONGCARD DIV and MOD need not call the functions ever.
>     (again, caveat, maybe for zero, maybe, not currently, but if we make trapping divide by zero controllable)
>  
>  
>  - Jay
> 
>  
> > From: hosking at cs.purdue.edu
> > To: hendrik at topoi.pooq.com
> > Date: Sun, 17 Jan 2010 15:19:21 -0600
> > CC: m3devel at elegosoft.com
> > Subject: Re: [M3devel] how division and modulo work in hand.c?
> > 
> > It calls the C routines in hand.c.
> > 
> > Sent from my iPhone
> > 
> > On Jan 17, 2010, at 2:48 PM, hendrik at topoi.pooq.com wrote:
> > 
> > > On Sun, Jan 17, 2010 at 11:39:03AM -0500, Tony Hosking wrote:
> > >>
> > >> This is a quote from the gcc internals manual. I've always wondered
> > >> why cm3cg uses the built-in FLOOR_DIV_EXPR/FLOOR_MOD_EXPR only for
> > >> known positive operands. What would be wrong about using them also
> > >> for negative operands?
> > >
> > > What does cm3cg use for operands that are not known to be positive?
> > >
> > > -- hendrik

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://m3lists.elegosoft.com/pipermail/m3devel/attachments/20100118/0b0f15fd/attachment-0002.html>


More information about the M3devel mailing list