re PR tree-optimization/81227 (ICE in get_single_symbol, at tree-vrp.c:799)
authorRichard Biener <rguenther@suse.de>
Wed, 28 Jun 2017 14:24:00 +0000 (14:24 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Wed, 28 Jun 2017 14:24:00 +0000 (14:24 +0000)
2017-06-28  Richard Biener  <rguenther@suse.de>

PR middle-end/81227
* fold-const.c (negate_expr_p): Use TYPE_UNSIGNED, not
TYPE_OVERFLOW_WRAPS.
* match.pd (negate_expr_p): Likewise.
* tree-ssa-reassoc.c (optimize_range_tests_diff): Use
fold_build2, not fold_binary.

* gcc.dg/pr81227.c: New testcase.

From-SVN: r249742

gcc/ChangeLog
gcc/fold-const.c
gcc/match.pd
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr81227.c [new file with mode: 0644]
gcc/tree-ssa-reassoc.c

index 293671b8ff285b952aca69a1aa35ac7a72209e63..34de7cf2bcef72958c81716b559eb131899db473 100644 (file)
@@ -1,3 +1,12 @@
+2017-06-28  Richard Biener  <rguenther@suse.de>
+
+       PR middle-end/81227
+       * fold-const.c (negate_expr_p): Use TYPE_UNSIGNED, not
+       TYPE_OVERFLOW_WRAPS.
+       * match.pd (negate_expr_p): Likewise.
+       * tree-ssa-reassoc.c (optimize_range_tests_diff): Use
+       fold_build2, not fold_binary.
+
 2017-06-28  Wilco Dijkstra  <wdijkstr@arm.com>
 
        * config/aarch64/aarch64 (aarch64_expand_mov_immediate):
index 379a30ea285acf6d78042bc1a3a5c152539b2b75..1bcbbb58154b94093dccb384357900f7214f21ee 100644 (file)
@@ -383,7 +383,7 @@ negate_expr_p (tree t)
   switch (TREE_CODE (t))
     {
     case INTEGER_CST:
-      if (INTEGRAL_TYPE_P (type) && TYPE_OVERFLOW_WRAPS (type))
+      if (INTEGRAL_TYPE_P (type) && TYPE_UNSIGNED (type))
        return true;
 
       /* Check that -CST will not overflow type.  */
index ede5504bdf1deccd2a43c8fa115324be8825b7bf..4c64b21b46394c72fcb4a6d6719791c4696bf09d 100644 (file)
@@ -914,7 +914,7 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
 (match negate_expr_p
  INTEGER_CST
  (if ((INTEGRAL_TYPE_P (type)
-       && TYPE_OVERFLOW_WRAPS (type))
+       && TYPE_UNSIGNED (type))
       || (!TYPE_OVERFLOW_SANITIZED (type)
          && may_negate_without_overflow_p (t)))))
 (match negate_expr_p
index d50a9d8c646acb1f741a75b94547c00dad5b72e1..a96d5abb65c591d0be6d3a8079ca8c8a22e63ba9 100644 (file)
@@ -1,3 +1,8 @@
+2017-06-28  Richard Biener  <rguenther@suse.de>
+
+       PR middle-end/81227
+       * gcc.dg/pr81227.c: New testcase.
+
 2017-06-28  Michael Meissner  <meissner@linux.vnet.ibm.com>
 
        PR target/81193
diff --git a/gcc/testsuite/gcc.dg/pr81227.c b/gcc/testsuite/gcc.dg/pr81227.c
new file mode 100644 (file)
index 0000000..bdaa8cb
--- /dev/null
@@ -0,0 +1,22 @@
+/* Copy of gcc.c-torture/compile/pr80443.c  */
+/* { dg-do compile } */
+/* { dg-options "-O2 -fwrapv" } */
+
+struct S { int a : 1; } b, c;
+signed char d, e, f;
+
+void
+foo ()
+{ 
+  while (f)
+    { 
+      signed char g = b.a;
+      if (g)
+       b.a = ~(1 + (d || c.a));
+      if (b.a < g && b.a)
+       g = 0;
+      if (b.a > c.a)
+       b.a = g;
+      c.a = e;
+    }
+}
index 35eb72ce31051ac79dfb1e2fd81d95e6626a599f..982ab790cb34e9b2b2336f7f53c59a2a965a64dc 100644 (file)
@@ -2561,7 +2561,7 @@ optimize_range_tests_diff (enum tree_code opcode, tree type,
   tem2 = fold_convert (type, tem2);
   lowi = fold_convert (type, lowi);
   mask = fold_build1 (BIT_NOT_EXPR, type, tem1);
-  tem1 = fold_binary (MINUS_EXPR, type,
+  tem1 = fold_build2 (MINUS_EXPR, type,
                      fold_convert (type, rangei->exp), lowi);
   tem1 = fold_build2 (BIT_AND_EXPR, type, tem1, mask);
   lowj = build_int_cst (type, 0);