Ciao,

4 set 2023, 15:19 da vinc...@vinc17.net:

> On 2023-09-04 09:52:23 +0200, marco.bodr...@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

Reply via email to