re PR tree-optimization/61684 (ICE at -Os and above on x86_64-linux-gnu in tree check...
authorJakub Jelinek <jakub@redhat.com>
Fri, 4 Jul 2014 08:32:56 +0000 (10:32 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 4 Jul 2014 08:32:56 +0000 (10:32 +0200)
PR tree-optimization/61684
* tree-ssa-ifcombine.c (recognize_single_bit_test): Make sure
rhs1 of conversion is a SSA_NAME before using SSA_NAME_DEF_STMT on it.

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

From-SVN: r212290

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

index 3b0f8ef..4965219 100644 (file)
@@ -1,3 +1,9 @@
+2014-07-04  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/61684
+       * tree-ssa-ifcombine.c (recognize_single_bit_test): Make sure
+       rhs1 of conversion is a SSA_NAME before using SSA_NAME_DEF_STMT on it.
+
 2014-07-04  Chung-Ju Wu  <jasonwucj@gmail.com>
            Kito Cheng  <kito@0xlab.org>
            Monk Chiang  <sh.chiang04@gmail.com>
index 9ea562b..5eee717 100644 (file)
@@ -1,3 +1,8 @@
+2014-07-04  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/61684
+       * gcc.c-torture/compile/pr61684.c: New test.
+
 2014-07-04  Thomas Schwinge  <thomas@codesourcery.com>
 
        * lib/g++-dg.exp (g++-dg-runtest): Change interface to match
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr61684.c b/gcc/testsuite/gcc.c-torture/compile/pr61684.c
new file mode 100644 (file)
index 0000000..f5b53b7
--- /dev/null
@@ -0,0 +1,15 @@
+/* PR tree-optimization/61684 */
+
+int a, c;
+static int *b = 0;
+short d;
+static short **e = 0;
+
+void
+foo ()
+{
+  for (; c < 1; c++)
+    ;
+  *e = &d;
+  a = d && (c && 1) & *b;
+}
index fa3c5b1..7e051a3 100644 (file)
@@ -233,7 +233,8 @@ recognize_single_bit_test (gimple cond, tree *name, tree *bit, bool inv)
       while (is_gimple_assign (stmt)
             && ((CONVERT_EXPR_CODE_P (gimple_assign_rhs_code (stmt))
                  && (TYPE_PRECISION (TREE_TYPE (gimple_assign_lhs (stmt)))
-                     <= TYPE_PRECISION (TREE_TYPE (gimple_assign_rhs1 (stmt)))))
+                     <= TYPE_PRECISION (TREE_TYPE (gimple_assign_rhs1 (stmt))))
+                 && TREE_CODE (gimple_assign_rhs1 (stmt)) == SSA_NAME)
                 || gimple_assign_ssa_name_copy_p (stmt)))
        stmt = SSA_NAME_DEF_STMT (gimple_assign_rhs1 (stmt));