Help stabilising mini-gmp
Marc Glisse
marc.glisse at inria.fr
Sun Nov 20 16:46:53 UTC 2016
On Sun, 20 Nov 2016, Niels Möller wrote:
> nisse at lysator.liu.se (Niels Möller) writes:
>
>>> It seems "trivially" reproducible on ppc64 though, both real metal
>>> versions and fake ones like ppceb-debv8 (and ppcel-debv8).
>>
>> I'll try to debug (if no one else beats me to it), but not today.
>
> I've logged in to ppceb-debv8, and it's easy to reproduce. No gdb
> installed, so I'm attempting printf debugging. And then I noticed that
> the test succeeds if adding a few debug printouts...
>
> I next tried adding -Wall to the command line flags, and I see
>
> gcc -std=gnu99 -m64 -mtune=power7 -O3 -Wall -I../.. -c
> /home/nisse/hack/gmp/mini-gmp/tests/t-signed.c -o t-signed.o
> /home/nisse/hack/gmp/mini-gmp/tests/t-signed.c: In function 'testmain':
> /home/nisse/hack/gmp/mini-gmp/tests/t-signed.c:45:26: warning: assuming
> signed overflow does not occur when assuming that (X - c) > X is always
> false [-Wstrict-overflow]
> if ((si < oi ? -1 : si > oi) != c)
> ^
> /home/nisse/hack/gmp/mini-gmp/tests/t-signed.c:45:21: warning: assuming
> signed overflow does not occur when assuming that (X + c) >= X is always
> true [-Wstrict-overflow]
> if ((si < oi ? -1 : si > oi) != c)
> ^
>
> I don't quite understand neither what the testcase is doing, nor what the
> warning means, since there's no subtraction in there.
After inlining, there are subtractions. check_si is called at least once
with oi = si + c (c is ±1). gcc simplifies the test si > si - 1 to true,
and warns that this optimization may break your program if you rely on
wrapping. The usefulness of such a warning is debatable, and we tend to
drop some of them from gcc when we think nobody will notice.
--
Marc Glisse
More information about the gmp-devel
mailing list