re PR tree-optimization/38807 (ice: gimple check: expected gimple_assign(error_mark...
authorJakub Jelinek <jakub@redhat.com>
Mon, 12 Jan 2009 11:11:40 +0000 (12:11 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Mon, 12 Jan 2009 11:11:40 +0000 (12:11 +0100)
PR tree-optimization/38807
* tree-ssa-reassoc.c (remove_visited_stmt_chain): Don't look at
gimple_visited_p unless stmt is GIMPLE_ASSIGN.

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

From-SVN: r143289

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/pr38807.c [new file with mode: 0644]
gcc/tree-ssa-reassoc.c

index ba53e7df4cc917205780d3027dd2aa1230d8f0d1..715cbfb94855a15f635a6599a0aeadc5d47c7b11 100644 (file)
@@ -1,3 +1,9 @@
+2009-01-12  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/38807
+       * tree-ssa-reassoc.c (remove_visited_stmt_chain): Don't look at
+       gimple_visited_p unless stmt is GIMPLE_ASSIGN.
+
 2009-01-11  Adam Nemet  <anemet@caviumnetworks.com>
 
        * expmed.c (store_bit_field_1): Properly truncate the paradoxical
index 41f53a92da6248ed0a4e8629fdcd0d64b0276b28..260504aa86508054fb2119d3e021b51144e52ea9 100644 (file)
@@ -1,3 +1,8 @@
+2009-01-12  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/38807
+       * gcc.c-torture/compile/pr38807.c: New test.
+
 2009-01-11  Adam Nemet  <anemet@caviumnetworks.com>
 
        * gcc.target/mips/ins-2.c: New test.
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr38807.c b/gcc/testsuite/gcc.c-torture/compile/pr38807.c
new file mode 100644 (file)
index 0000000..8b05d08
--- /dev/null
@@ -0,0 +1,23 @@
+/* PR tree-optimization/38807 */
+
+int
+baz (short x)
+{
+  return x;
+}
+
+int a, b;
+
+int
+bar (int x)
+{
+  if (baz (a ^ x ^ a))
+    return b;
+  return 0;
+}
+
+int
+foo (void)
+{
+  return bar (a == 0 || 1 == 1 - a) ? 1 : bar (1 && a);
+}
index d539398c5c722295f310f887531bc3749a2062f8..d28e1b620ff068f59cd1500ada49ddfed2f30390 100644 (file)
@@ -1,5 +1,5 @@
 /* Reassociation for trees.
-   Copyright (C) 2005, 2007, 2008 Free Software Foundation, Inc.
+   Copyright (C) 2005, 2007, 2008, 2009 Free Software Foundation, Inc.
    Contributed by Daniel Berlin <dan@dberlin.org>
 
 This file is part of GCC.
@@ -1279,7 +1279,8 @@ remove_visited_stmt_chain (tree var)
       if (TREE_CODE (var) != SSA_NAME || !has_zero_uses (var))
        return;
       stmt = SSA_NAME_DEF_STMT (var);
-      if (!gimple_visited_p (stmt))
+      if (!is_gimple_assign (stmt)
+         || !gimple_visited_p (stmt))
        return;
       var = gimple_assign_rhs1 (stmt);
       gsi = gsi_for_stmt (stmt);