68000 issue in longlong.h

selco at t-online.de selco at t-online.de
Wed Mar 3 11:50:36 UTC 2021


Hello,
I am compiling and testing libgmp for AmigaOS. Yes, I am crazy.
 
I use<https://gmplib.org/download/gmp/gmp-6.2.1.tar.lz>
Thanks to bebbo's gcc https://github.com/bebbo/amiga-gcc 
<https://github.com/bebbo/amiga-gcc> I was quite successful. I had some 
issues in the tests hovever.
For instance t-conv, t-sqrt and t-sqrt_ui failed. The bugs disappeared when 
I compiled without optimization and appeared when I used -O2, so I 
suspected a compiler bug and reported that to the Amiga gcc6 maintainer. He 
looked after the problem and found an issue inside libgmp's code.
 
The bug is inside gmp's header longlong.h:1220, where asm for 68000 is 
defined:
 
wrong code:
...
" | End inlined umul_ppmm" \
: "=&d" (xh), "=&d" (xl), \
"=d" (__umul_tmp1), "=&d" (__umul_tmp2) \
: "%2" ((USItype)(a)), "d" ((USItype)(b))); \
 
correction:
...
" | End inlined umul_ppmm" \
: "=&d" (xh), "=&d" (xl), \
"=&d" (__umul_tmp1), "=&d" (__umul_tmp2) \        <---  an & must be added 
after the =
: "%2" ((USItype)(a)), "d" ((USItype)(b))); \
 
With this correction these tests pass on 68000.
 
Best regards



More information about the gmp-bugs mailing list