re PR middle-end/42716 (ICE in extract_range_from_assert, at tree-vrp.c:1423)
authorRichard Guenther <rguenther@suse.de>
Wed, 13 Jan 2010 13:31:13 +0000 (13:31 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Wed, 13 Jan 2010 13:31:13 +0000 (13:31 +0000)
2010-01-13  Richard Guenther  <rguenther@suse.de>

PR middle-end/42716
* fold-const.c (fold_unary_loc): Fold INDIRECT_REFs.

* gcc.c-torture/compile/pr42716.c: New testcase.

From-SVN: r155859

gcc/ChangeLog
gcc/fold-const.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/pr42716.c [new file with mode: 0644]

index 5b291e651380c2597f9ec5e479b53f83612c92a0..1d66583818e2077b2e789ae600e8cd65e8da86a2 100644 (file)
@@ -1,3 +1,8 @@
+2010-01-13  Richard Guenther  <rguenther@suse.de>
+
+       PR middle-end/42716
+       * fold-const.c (fold_unary_loc): Fold INDIRECT_REFs.
+
 2010-01-13  Jakub Jelinek  <jakub@redhat.com>
 
        PR debug/41371
index e1126219689c4bc1cac7dacb4634e183ef942b2a..9e40296123cd07448561c9213a35e281fcf21c29 100644 (file)
@@ -8942,6 +8942,19 @@ fold_unary_loc (location_t loc, enum tree_code code, tree type, tree op0)
        }
       return NULL_TREE;
 
+    case INDIRECT_REF:
+      /* Fold *&X to X if X is an lvalue.  */
+      if (TREE_CODE (op0) == ADDR_EXPR)
+       {
+         tree op00 = TREE_OPERAND (op0, 0);
+         if ((TREE_CODE (op00) == VAR_DECL
+              || TREE_CODE (op00) == PARM_DECL
+              || TREE_CODE (op00) == RESULT_DECL)
+             && !TREE_READONLY (op00))
+           return op00;
+       }
+      return NULL_TREE;
+
     default:
       return NULL_TREE;
     } /* switch (code) */
index f8532afa361eb8c9bb2bb84a1cefbf8ac941584c..38241e23fbb5656b05bda074dbadd8066fc1f165 100644 (file)
@@ -1,3 +1,8 @@
+2010-01-13  Richard Guenther  <rguenther@suse.de>
+
+       PR middle-end/42716
+       * gcc.c-torture/compile/pr42716.c: New testcase.
+
 2010-01-13  Richard Guenther  <rguenther@suse.de>
 
        PR lto/42678
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr42716.c b/gcc/testsuite/gcc.c-torture/compile/pr42716.c
new file mode 100644 (file)
index 0000000..e52df0f
--- /dev/null
@@ -0,0 +1,18 @@
+static short foo (long long si1, short si2)
+{
+  return si1 > 0 && si2 > 0 || si1 < 0
+      && si2 < 0 && si1 < 1 - si2 ? : si1 + si2;
+}
+
+int g_13;
+unsigned g_17;
+
+int safe (int, int);
+
+void bar (short p_51, short * p_52)
+{
+  int *const l_55 = &g_13;
+  if (safe (*p_52, g_13 != foo (*p_52 & *l_55 == g_13 && g_17 >= 1, 0)))
+    {
+    }
+}