OSDN Git Service

PR tree-optimization/38807
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 12 Jan 2009 11:11:40 +0000 (11:11 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 12 Jan 2009 11:11:40 +0000 (11:11 +0000)
* 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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@143289 138bc75d-0d04-0410-961f-82ee72b054a4

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

index ba53e7d..715cbfb 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 41f53a9..260504a 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 d539398..d28e1b6 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);