modulus question
Andrew Pinski
pinskia@physics.uc.edu
Mon Aug 9 21:02:00 GMT 2004
On Aug 9, 2004, at 1:31 PM, Pat Haugen wrote:
> Wondering if someone could explain why I'm seeing the following
> difference
> when doing a mod by 2. The final generated code ends up with the
> 'xor/and'
> sequence for mod by 2 but the simpler 'and' for mod by 4 (or 8, or 16,
> ...). This is from mainline, powerpc64-unknown-linux-gnu.
>
> int i;
> void test1(unsigned int u, unsigned int u2)
> {
> if ((u % 2) == 0)
> i = 1;
>
>
> if ((u2 % 4) == 0)
> i = 2;
>
> }
Fold is changing (u%2)==0 into (u&1)==0 which gets changed to ((u^1) &
1) != 0.
Why it does this is unknown to me.
-- Pinski
More information about the Gcc
mailing list