]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR tree-optimization/32694 (ICE with long long arithmetic)
authorJakub Jelinek <jakub@redhat.com>
Tue, 25 Sep 2007 15:14:42 +0000 (17:14 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 25 Sep 2007 15:14:42 +0000 (17:14 +0200)
PR tree-optimization/32694
2006-11-08  Roger Sayle  <roger@eyesopen.com>
* tree-ssa-propagate.c (set_rhs): Verify tcc_comparison the same way
as tcc_binary.
* tree-ssa-ccp.c (fold_stmt_r) <COND_EXPR>: Use set_rhs to modify
the condition after calling fold_binary.

* gcc.c-torture/compile/20070925-1.c: New test.

From-SVN: r128766

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/20070925-1.c [new file with mode: 0644]
gcc/tree-ssa-ccp.c
gcc/tree-ssa-propagate.c

index 42d02125d917185b5d3d56458c92a43bf5b13df5..4e676abd105b79e6bbfd1ed25684aaca858d3ebf 100644 (file)
@@ -1,3 +1,12 @@
+2007-09-25  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/32694
+       2006-11-08  Roger Sayle  <roger@eyesopen.com>
+       * tree-ssa-propagate.c (set_rhs): Verify tcc_comparison the same way
+       as tcc_binary.
+       * tree-ssa-ccp.c (fold_stmt_r) <COND_EXPR>: Use set_rhs to modify
+       the condition after calling fold_binary.
+
 2007-09-24  Jakub Jelinek  <jakub@redhat.com>
 
        PR debug/33316
index 7bfa71fc79c23029b500ce9cc0477344697cbafc..a301ef8bdb3551d2c457f686bd0d99ebc1f44870 100644 (file)
@@ -1,3 +1,8 @@
+2007-09-25  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/32694
+       * gcc.c-torture/compile/20070925-1.c: New test.
+
 2007-09-24  Jakub Jelinek  <jakub@redhat.com>
 
        PR debug/33316
diff --git a/gcc/testsuite/gcc.c-torture/compile/20070925-1.c b/gcc/testsuite/gcc.c-torture/compile/20070925-1.c
new file mode 100644 (file)
index 0000000..188193b
--- /dev/null
@@ -0,0 +1,22 @@
+/* PR tree-optimization/32694 */
+
+typedef signed long long int WordS64;
+typedef unsigned long long int Word64;
+
+int
+foo (Word64 * p)
+{
+  while (1)
+    {
+      WordS64 c = 0x1llu;
+      WordS64 x = *p;
+      if (c >= 0)
+       {
+         if (x > (WordS64) 0x7FFFFFFFFFFFFFFFll - c)
+           return 6;
+       }
+      else if (x < (WordS64) 0x8000000000000000ll - c)
+       return 7;
+      p++;
+    }
+}
index f16652d61ef6c2345341999db83e4c1534d73f56..f485b02e4cf220b0324fc84641d8d58c1afcfaa8 100644 (file)
@@ -2062,12 +2062,13 @@ fold_stmt_r (tree *expr_p, int *walk_subtrees, void *data)
          tem = fold_binary (TREE_CODE (op0), TREE_TYPE (op0),
                             TREE_OPERAND (op0, 0),
                             TREE_OPERAND (op0, 1));
-         set = tem && is_gimple_condexpr (tem);
+         set = tem && set_rhs (expr_p, tem);
          fold_undefer_overflow_warnings (set, fold_stmt_r_data->stmt, 0);
          if (set)
-           TREE_OPERAND (expr, 0) = tem;
-         t = expr;
-          break;
+           {
+             t = *expr_p;
+             break;
+           }
         }
 
     default:
index 56d6ecad97a32de79a48a3f56c8c5d04ecd2f564..c01a2cf65835b9c742e98ca3dc09e989e5448ce1 100644 (file)
@@ -570,7 +570,8 @@ set_rhs (tree *stmt_p, tree expr)
   ssa_op_iter iter;
 
   /* Verify the constant folded result is valid gimple.  */
-  if (TREE_CODE_CLASS (code) == tcc_binary)
+  if (TREE_CODE_CLASS (code) == tcc_binary
+      || TREE_CODE_CLASS (code) == tcc_comparison)
     {
       if (!is_gimple_val (TREE_OPERAND (expr, 0))
          || !is_gimple_val (TREE_OPERAND (expr, 1)))