[PATCH] libm: Fixing overflow handling issue for scalbnf and scalbn

Corinna Vinschen vinschen@redhat.com
Wed Jul 21 07:59:44 GMT 2021


On Jul 20 09:12, Keith Packard wrote:
> Kito Cheng <kito.cheng@sifive.com> writes:
> 
> > cc Aldy Hernandez <aldyh@redhat.com> and Andrew MacLeod <amacleod@redhat.com>,
> > 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
> spec.
> 
> 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
> practical here.
> 
> 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.
> 
> -- 
> -keith

Thanks for verifying.  PUshed.


Thanks,
Corinna



More information about the Newlib mailing list