re PR middle-end/86122 (ICE in useless_type_conversion_p, at gimple-expr.c:87)
authorJakub Jelinek <jakub@redhat.com>
Thu, 14 Jun 2018 19:07:45 +0000 (21:07 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Thu, 14 Jun 2018 19:07:45 +0000 (21:07 +0200)
PR middle-end/86122
* match.pd ((A +- CST1) +- CST2): Punt if last resort
unsigned_type_for returns NULL.

* gcc.c-torture/compile/pr86122.c: New test.

From-SVN: r261606

gcc/ChangeLog
gcc/match.pd
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/pr86122.c [new file with mode: 0644]

index 65284fb6fbcb51e28e629a15c00a46217b13c69f..8e360fb0e8d46b242a5b07fd811f060736ac737b 100644 (file)
@@ -1,5 +1,9 @@
 2018-06-14  Jakub Jelinek  <jakub@redhat.com>
 
+       PR middle-end/86122
+       * match.pd ((A +- CST1) +- CST2): Punt if last resort
+       unsigned_type_for returns NULL.
+
        PR target/85945
        * lower-subreg.c (find_decomposable_subregs): Don't decompose float
        subregs of multi-word pseudos unless the float mode has word size.
index 14386da070b0b71c59981310843505680872b1df..f70a88c362ef7d00450995cff893526d2ed59c8f 100644 (file)
@@ -1771,10 +1771,11 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
           (neg_inner_op @0 { wide_int_to_tree (type, wi::to_wide (cst)); })
           /* Last resort, use some unsigned type.  */
           (with { tree utype = unsigned_type_for (type); }
-           (view_convert (inner_op
-                          (view_convert:utype @0)
-                          (view_convert:utype
-                           { drop_tree_overflow (cst); })))))))))))))
+           (if (utype)
+            (view_convert (inner_op
+                           (view_convert:utype @0)
+                           (view_convert:utype
+                            { drop_tree_overflow (cst); }))))))))))))))
 
   /* (CST1 - A) +- CST2 -> CST3 - A  */
   (for outer_op (plus minus)
index 92bc519e5583b5c426e7a0cadca2e4544a794da8..9c15279f09bc68c4dc4c5bcca988363fb1f0bbc6 100644 (file)
@@ -1,5 +1,8 @@
 2018-06-14  Jakub Jelinek  <jakub@redhat.com>
 
+       PR middle-end/86122
+       * gcc.c-torture/compile/pr86122.c: New test.
+
        P0624R2 - Default constructible and assignable stateless lambdas
        * g++.dg/cpp2a/lambda1.C: New test.
        * g++.dg/cpp0x/lambda/lambda-ice2.C: Adjust expected diagnostics
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr86122.c b/gcc/testsuite/gcc.c-torture/compile/pr86122.c
new file mode 100644 (file)
index 0000000..0a4fd14
--- /dev/null
@@ -0,0 +1,17 @@
+/* PR middle-end/86122 */
+
+_Complex int
+foo (_Complex int x)
+{
+  x += __INT_MAX__;
+  x += 1;
+  return x;
+}
+
+_Complex int
+bar (_Complex int x)
+{
+  x += 1;
+  x += __INT_MAX__;
+  return x;
+}