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.
This commit is contained in:
Richard Biener 2021-11-04 09:17:18 +01:00
parent d43fc1df73
commit d136035016
2 changed files with 13 additions and 3 deletions

View File

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

View File

@ -0,0 +1,8 @@
/* { dg-do compile } */
/* { dg-options "-O -frounding-math" } */
float
foo (void)
{
return (float) 0x1699925 * 1.1;
}