public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-4898] rtl-optimization/103075 - avoid ICEing on unfolded int-to-float converts
@ 2021-11-04 12:33 Richard Biener
  0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2021-11-04 12:33 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:d13603501680fcdbb933cb086cd01fcc39be1908

commit r12-4898-gd13603501680fcdbb933cb086cd01fcc39be1908
Author: Richard Biener <rguenther@suse.de>
Date:   Thu Nov 4 09:17:18 2021 +0100

    rtl-optimization/103075 - avoid ICEing on unfolded int-to-float converts
    
    The following avoids asserting in exact_int_to_float_conversion_p that
    the argument is not constant which it in fact can be with
    -frounding-math and inexact int-to-float conversions.  Say so.
    
    2021-11-04  Richard Biener  <rguenther@suse.de>
    
            PR rtl-optimization/103075
            * simplify-rtx.c (exact_int_to_float_conversion_p): Return
            false for a VOIDmode operand.
    
            * gcc.dg/pr103075.c: New testcase.

Diff:
---
 gcc/simplify-rtx.c              | 8 +++++---
 gcc/testsuite/gcc.dg/pr103075.c | 8 ++++++++
 2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/gcc/simplify-rtx.c b/gcc/simplify-rtx.c
index 9038affa036..eea747664d4 100644
--- a/gcc/simplify-rtx.c
+++ b/gcc/simplify-rtx.c
@@ -899,10 +899,12 @@ simplify_context::simplify_unary_operation (rtx_code code, machine_mode mode,
 static bool
 exact_int_to_float_conversion_p (const_rtx op)
 {
-  int out_bits = significand_size (GET_MODE_INNER (GET_MODE (op)));
   machine_mode op0_mode = GET_MODE (XEXP (op, 0));
-  /* Constants shouldn't reach here.  */
-  gcc_assert (op0_mode != VOIDmode);
+  /* Constants can reach here with -frounding-math, if they do then
+     the conversion isn't exact.  */
+  if (op0_mode == VOIDmode)
+    return false;
+  int out_bits = significand_size (GET_MODE_INNER (GET_MODE (op)));
   int in_prec = GET_MODE_UNIT_PRECISION (op0_mode);
   int in_bits = in_prec;
   if (HWI_COMPUTABLE_MODE_P (op0_mode))
diff --git a/gcc/testsuite/gcc.dg/pr103075.c b/gcc/testsuite/gcc.dg/pr103075.c
new file mode 100644
index 00000000000..b332fb01434
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr103075.c
@@ -0,0 +1,8 @@
+/* { dg-do compile } */
+/* { dg-options "-O -frounding-math" } */
+
+float
+foo (void)
+{
+  return (float) 0x1699925 * 1.1;
+}


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-11-04 12:33 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-04 12:33 [gcc r12-4898] rtl-optimization/103075 - avoid ICEing on unfolded int-to-float converts Richard Biener

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).