bug in longlong.h for aarch64 sub_ddmmss

Torbjörn Granlund tg at gmplib.org
Wed Jun 17 10:52:03 UTC 2020


nisse at lysator.liu.se (Niels Möller) writes:

  And, which I guess is more relevant in the sub_ddmmss context, it also
  means that there's little need for separate instructions for adding and
  subtracting constants.

The error we struck here for ARM and (one of the errors) for PPC was
that we added 0 instead of subtracting zero, the latter meaning adding
~0 + 1.

Using the ARM "subs rd,rm,imm12" instruction, we compute

    {cout, rd} = rm + ~imm + 1

while the "adds rd,rm,imm12" instruction, we compute

    {cout, rd} = rm + imm

.  which is quite different.  The former will for example always set
cout when rm = imm = 0 as in Vincent's example.  The latter will never
set carry when imm = 0 or rm = 0;


-- 
Torbjörn
Please encrypt, key id 0xC8601622


More information about the gmp-bugs mailing list