[prev in list] [next in list] [prev in thread] [next in thread]
List: gmp-bugs
Subject: Re: Unsigned integer overflow in `toom_eval_pm2.c`
From: marco.bodrato () tutanota ! com
Date: 2023-09-05 17:39:51
Message-ID: NdaQSss--7-9 () tutanota ! com
[Download RAW message or body]
Ciao,
4 set 2023, 15:19 da vincent@vinc17.net:
> On 2023-09-04 09:52:23 +0200, marco.bodrato@tutanota.com wrote:
>
>> Should the value ~0 be written as ~0U to be correctly assigned to an
>> unsigned?
>>
>
> IMHO, this would be better as this would make the signedness of
> the types more consistent
>
Ok, I changed all the
neg = (v<0)? ~0:0;
into
neg = - (unsigned) (v<0):
For x86-64, gcc generates exactly the same code:
# m.c:2: return v<0?~0:0;
movl %edi, %eax
sarl $31, %eax
# m.c:6: return -(unsigned)(v<0);
movl %edi, %eax
sarl $31, %eax
All but one. Everything started with a question on the line:
neg ^= ((k & 1) - 1);
Well, now neg before this line contains 0 or 1, so that the line is now
neg ^= 1 ^ k & 1;
And it is transformed to a mask after that,
Changes pushed here:
https://gmplib.org/repo/gmp/rev/ef441e461f42
Ĝis,
m
_______________________________________________
gmp-bugs mailing list
gmp-bugs@gmplib.org
https://gmplib.org/mailman/listinfo/gmp-bugs
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic