gm2
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Gm2] Behaviour of DIV and MOD in PIM4


From: Gaius Mulley
Subject: Re: [Gm2] Behaviour of DIV and MOD in PIM4
Date: Wed, 23 Mar 2016 18:32:18 +0000
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux)

Benjamin Kowarsch <address@hidden> writes:

> Hi Gaius,
>
> On 23 March 2016 at 19:32, Gaius Mulley wrote:
>
>     I was thinking of adding an optional -fwhatever runtime check for
>     negative values given that this might appear quite dangerous,
>
> If the target type of the expression is an unsigned integer, then of
> course the result may not be negative and you need a check indeed.
>
> However, if the target type of the expression is a signed integer,
> then it doesn't matter whether the result is positive or negative and
> you don't need to insert any checks.

Hi Benjamin,

I think the constraint on P28 of PIM4 says that the modulus value, r,
must satisfy:  0 < r < y

where:

   q = x DIV y
   r = x MOD y

and x = q * y + r

> I am not sure why you want to allow that check to be switchable
> though, in my view the check should always be present in the former
> case and never in the latter.

I was going to add a check (user selectable) for negative operands to
DIV and MOD as these expressions will generate different results
depending upon whether -fiso, -fpim3 or -fpim4 were selected.  Or they
would generate compile time warnings if negative constants were
propagated etc

regards,
Gaius



reply via email to

[Prev in Thread] Current Thread [Next in Thread]