public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jeff Law <jeffreyalaw@gmail.com>
To: liuhongt <hongtao.liu@intel.com>, gcc-patches@gcc.gnu.org
Cc: jakub@redhat.com
Subject: Re: [PATCH] Don't simplify NAN/INF or out-of-range constant for FIX/UNSIGNED_FIX.
Date: Tue, 4 Jun 2024 08:27:41 -0600	[thread overview]
Message-ID: <ddfbcbea-8d12-48a5-bdc4-91d0e299f08c@gmail.com> (raw)
In-Reply-To: <20240527010803.2851191-1-hongtao.liu@intel.com>



On 5/26/24 7:08 PM, liuhongt wrote:
> Update in V2:
> Guard constant folding for overflow value in
> fold_convert_const_int_from_real with flag_trapping_math.
> Add -fno-trapping-math to related testcases which warn for overflow
> in conversion from floating point to integer.
> 
> Bootstrapped and regtested on x86_64-pc-linux-gnu{-m32,}.
> Ok for trunk?
> 
> According to IEEE standard, for conversions from floating point to
> integer. When a NaN or infinite operand cannot be represented in the
> destination format and this cannot otherwise be indicated, the invalid
> operation exception shall be signaled. When a numeric operand would
> convert to an integer outside the range of the destination format, the
> invalid operation exception shall be signaled if this situation cannot
> otherwise be indicated.
> 
> The patch prevent simplication of the conversion from floating point
> to integer for NAN/INF/out-of-range constant when flag_trapping_math.
> 
> gcc/ChangeLog:
> 
> 	PR rtl-optimization/100927
> 	PR rtl-optimization/115161
> 	PR rtl-optimization/115115
> 	* simplify-rtx.cc (simplify_const_unary_operation): Prevent
> 	simplication of FIX/UNSIGNED_FIX for NAN/INF/out-of-range
> 	constant when flag_trapping_math.
> 	* fold-const.cc (fold_convert_const_int_from_real): Don't fold
> 	for overflow value when_trapping_math.
> 
> gcc/testsuite/ChangeLog:
> 
> 	* gcc.dg/pr100927.c: New test.
> 	* c-c++-common/Wconversion-1.c: Add -fno-trapping-math.
> 	* c-c++-common/dfp/convert-int-saturate.c: Ditto.
> 	* g++.dg/ubsan/pr63956.C: Ditto.
> 	* g++.dg/warn/Wconversion-real-integer.C: Ditto.
> 	* gcc.c-torture/execute/20031003-1.c: Ditto.
> 	* gcc.dg/Wconversion-complex-c99.c: Ditto.
> 	* gcc.dg/Wconversion-real-integer.c: Ditto.
> 	* gcc.dg/c90-const-expr-11.c: Ditto.
> 	* gcc.dg/overflow-warn-8.c: Ditto.
OK.  Thanks.

jeff



      reply	other threads:[~2024-06-04 14:27 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-22  1:57 liuhongt
2024-05-22  7:46 ` Richard Biener
2024-05-22  7:59   ` Jakub Jelinek
2024-05-23  5:11     ` Hongtao Liu
2024-05-27  1:08       ` liuhongt
2024-06-04 14:27         ` Jeff Law [this message]

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=ddfbcbea-8d12-48a5-bdc4-91d0e299f08c@gmail.com \
    --to=jeffreyalaw@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=hongtao.liu@intel.com \
    --cc=jakub@redhat.com \
    /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).