From: Jakub Jelinek <jakub@redhat.com>
To: Richard Biener <rguenther@suse.de>
Cc: gcc-patches@gcc.gnu.org, joseph@codesourcery.com
Subject: Re: [PATCH] middle-end/84407 - honor -frounding-math for int to float conversion
Date: Thu, 28 Oct 2021 13:52:52 +0200 [thread overview]
Message-ID: <20211028115252.GP304296@tucnak> (raw)
In-Reply-To: <2qq2o881-1r56-7ooq-37o7-70n599n773r8@fhfr.qr>
On Thu, Oct 28, 2021 at 01:32:17PM +0200, Richard Biener wrote:
> diff --git a/gcc/simplify-rtx.c b/gcc/simplify-rtx.c
> index f38b6d7d31c..a16395befcd 100644
> --- a/gcc/simplify-rtx.c
> +++ b/gcc/simplify-rtx.c
> @@ -1917,6 +1917,19 @@ simplify_const_unary_operation (enum rtx_code code, machine_mode mode,
> return 0;
>
> d = real_value_truncate (mode, d);
> +
> + /* Avoid the folding if flag_rounding_math is on and the
> + conversion is not exact. */
> + if (HONOR_SIGN_DEPENDENT_ROUNDING (mode))
> + {
> + bool fail = false;
> + wide_int w = real_to_integer (&d, &fail,
> + GET_MODE_PRECISION
> + (as_a <scalar_int_mode> (op_mode)));
> + if (fail || wi::ne_p (w, wide_int (rtx_mode_t (op, op_mode))))
> + return 0;
> + }
> +
> return const_double_from_real_value (d, mode);
> }
> else if (code == UNSIGNED_FLOAT && CONST_SCALAR_INT_P (op))
What about the else if case (i.e. UNSIGNED_FLOAT)?
And I think it would be nice to test the simplify-rtx.c code somewhere,
perhaps gcc/testsuite/gcc.dg/rtl/x86_64 testcase and check that we
simplify with -frounding-math e.g. UNSIGNED_FLOAT from DImode
0x8000000000000000 or FLOAT or UNSIGNED_FLOAT from DImode
0x7ffffffffffffc00, but will not fold FLOAT or UNSIGNED_FLOAT from
DImode 0x7ffffffffffffc01 or 0x7fffffffffffffff.
Jakub
next prev parent reply other threads:[~2021-10-28 11:53 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-28 11:32 Richard Biener
2021-10-28 11:52 ` Jakub Jelinek [this message]
2021-10-28 12:24 ` Richard Biener
2021-10-28 12:38 ` Jakub Jelinek
2021-10-28 12:44 ` Richard Biener
2021-10-28 12:40 ` Richard Biener
2021-10-28 13:22 ` Jakub Jelinek
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=20211028115252.GP304296@tucnak \
--to=jakub@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=joseph@codesourcery.com \
--cc=rguenther@suse.de \
/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).