[PATCH] libm: Fixing overflow handling issue for scalbnf and scalbn
Tue Jul 20 16:12:36 GMT 2021
Kito Cheng <firstname.lastname@example.org> writes:
> cc Aldy Hernandez <email@example.com> and Andrew MacLeod <firstname.lastname@example.org>,
> they are author of new VRP analysis for GCC, just to make sure I didn't
> mis-understanding or mis-interpreting anything on GCC site.
> GCC 11 have better value range analysis, that give GCC more confidence
> to perform more aggressive optimization, but it cause scalbn/scalbnf get
> wrong result.
C doesn't specify what happens when signed integer values overflow;
compiler developers believe that gives them the license to do this kind
of "optimization". This patch makes the code more compliant with the C
The only way to get known overflow behavior would be to use unsigned
integers, but as this code depends on signed comparisons, that isn't
I've added tests for this case to the picolibc test suite and verified
that your patch corrects this issue on 32-bit ARM using GCC 11.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 832 bytes
Desc: not available
More information about the Newlib