re PR rtl-optimization/85300 (ICE in exact_int_to_float_conversion_p, at simplify...
authorJakub Jelinek <jakub@redhat.com>
Tue, 10 Apr 2018 15:31:57 +0000 (17:31 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 10 Apr 2018 15:31:57 +0000 (17:31 +0200)
PR rtl-optimization/85300
* combine.c (subst): Handle subst of CONST_SCALAR_INT_P new_rtx also
into FLOAT and UNSIGNED_FLOAT like ZERO_EXTEND, return a CLOBBER if
simplify_unary_operation fails.

* gcc.dg/pr85300.c: New test.

From-SVN: r259285

gcc/ChangeLog
gcc/combine.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr85300.c [new file with mode: 0644]

index aee206041a392cea37bb0241e8af51abe70314f0..f50d99a948f97e3b99521475e0910fe4614470fd 100644 (file)
@@ -1,3 +1,10 @@
+2018-04-10  Jakub Jelinek  <jakub@redhat.com>
+
+       PR rtl-optimization/85300
+       * combine.c (subst): Handle subst of CONST_SCALAR_INT_P new_rtx also
+       into FLOAT and UNSIGNED_FLOAT like ZERO_EXTEND, return a CLOBBER if
+       simplify_unary_operation fails.
+
 2018-04-10  Martin Liska  <mliska@suse.cz>
 
        * gdbhooks.py: Add pretty-printers for varpool_node, symtab_node,
index ff672ad2adbebb37b9566c99b696bb66fcaa1639..3ad050fecf1a76bce932f32c91e52ad25c8480b6 100644 (file)
@@ -5575,11 +5575,15 @@ subst (rtx x, rtx from, rtx to, int in_dest, int in_cond, int unique_copy)
                    x = gen_rtx_CLOBBER (mode, const0_rtx);
                }
              else if (CONST_SCALAR_INT_P (new_rtx)
-                      && GET_CODE (x) == ZERO_EXTEND)
+                      && (GET_CODE (x) == ZERO_EXTEND
+                          || GET_CODE (x) == FLOAT
+                          || GET_CODE (x) == UNSIGNED_FLOAT))
                {
-                 x = simplify_unary_operation (ZERO_EXTEND, GET_MODE (x),
-                                               new_rtx, GET_MODE (XEXP (x, 0)));
-                 gcc_assert (x);
+                 x = simplify_unary_operation (GET_CODE (x), GET_MODE (x),
+                                               new_rtx,
+                                               GET_MODE (XEXP (x, 0)));
+                 if (!x)
+                   return gen_rtx_CLOBBER (VOIDmode, const0_rtx);
                }
              else
                SUBST (XEXP (x, i), new_rtx);
index 7bd4b1d4fb41802cb1e178563a4a9b157994b212..f1da5c359b0caa7ddf73860cf26b4d49218032fa 100644 (file)
@@ -1,3 +1,8 @@
+2018-04-10  Jakub Jelinek  <jakub@redhat.com>
+
+       PR rtl-optimization/85300
+       * gcc.dg/pr85300.c: New test.
+
 2018-04-10  David Malcolm  <dmalcolm@redhat.com>
 
        PR c++/85110
diff --git a/gcc/testsuite/gcc.dg/pr85300.c b/gcc/testsuite/gcc.dg/pr85300.c
new file mode 100644 (file)
index 0000000..87a30b8
--- /dev/null
@@ -0,0 +1,16 @@
+/* PR rtl-optimization/85300 */
+/* { dg-do compile } */
+/* { dg-options "-O1 -g -funroll-all-loops -fno-tree-ter -fno-web" } */
+
+void
+foo (double x, unsigned char y)
+{
+  while ((int) x < 1)
+    {
+      float a;
+
+      a = y | 0x100;
+      y = 0;
+      x = a;
+    }
+}