public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
From: Keith Packard <keithp@keithp.com>
To: Kito Cheng <kito.cheng@sifive.com>,
	newlib@sourceware.org, kito.cheng@gmail.com,
	Aldy Hernandez <aldyh@redhat.com>,
	Andrew MacLeod <amacleod@redhat.com>
Cc: Kito Cheng <kito.cheng@sifive.com>
Subject: Re: [PATCH] libm: Fixing overflow handling issue for scalbnf and scalbn
Date: Tue, 20 Jul 2021 09:12:36 -0700	[thread overview]
Message-ID: <87wnplnevf.fsf@keithp.com> (raw)
In-Reply-To: <20210719085022.8157-1-kito.cheng@sifive.com>

[-- Attachment #1: Type: text/plain, Size: 972 bytes --]

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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

  reply	other threads:[~2021-07-20 16:12 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-19  8:50 Kito Cheng
2021-07-20 16:12 ` Keith Packard [this message]
2021-07-21  7:59   ` Corinna Vinschen
2021-07-21 23:33     ` Keith Packard

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87wnplnevf.fsf@keithp.com \
    --to=keithp@keithp.com \
    --cc=aldyh@redhat.com \
    --cc=amacleod@redhat.com \
    --cc=kito.cheng@gmail.com \
    --cc=kito.cheng@sifive.com \
    --cc=newlib@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).