diff mbox

Fix PR tree-optimization/49610

Message ID CAKSNEw55dWxyL46+THcN3LJwyDH3aciMx=dkdsexoNPY_hD1Uw@mail.gmail.com
State New
Headers show

Commit Message

Ira Rosen July 3, 2011, 10:15 a.m. UTC
Hi,

This patch adds a missing check that a basic blocks exists before using it.

Bootstrapped and tested on powerpc64-suse-linux.
Committed.

Ira

ChangeLog:

   PR tree-optimization/49610
   * tree-vect-loop.c (vect_is_slp_reduction): Check that DEF_STMT has
  a basic block.

testsuite/ChangeLog:

   PR tree-optimization/49610
   * gcc.dg/vect/pr49610.c: New test.
diff mbox

Patch

Index: testsuite/gcc.dg/vect/pr49610.c
===================================================================
--- testsuite/gcc.dg/vect/pr49610.c     (revision 0)
+++ testsuite/gcc.dg/vect/pr49610.c     (revision 0)
@@ -0,0 +1,12 @@ 
+/* { dg-do compile } */
+
+extern int g_7;
+void func_13(int p_17) {
+  int i;
+    for (i=0; i < 16; i = (signed char)(i+1)) {
+        g_7 &= p_17;
+        g_7 &= (p_17 > 1);
+    }
+}
+
+/* { dg-final { cleanup-tree-dump "vect" } } */
Index: tree-vect-loop.c
===================================================================
--- tree-vect-loop.c    (revision 175785)
+++ tree-vect-loop.c    (working copy)
@@ -1823,6 +1823,7 @@  vect_is_slp_reduction (loop_vec_info loop_info, gi
             ("vect_internal_def"), or it's an induction (defined by a
             loop-header phi-node).  */
           if (def_stmt
+              && gimple_bb (def_stmt)
              && flow_bb_inside_loop_p (loop, gimple_bb (def_stmt))
               && (is_gimple_assign (def_stmt)
                   || is_gimple_call (def_stmt)
@@ -1852,6 +1853,7 @@  vect_is_slp_reduction (loop_vec_info loop_info, gi
             ("vect_internal_def"), or it's an induction (defined by a
             loop-header phi-node).  */
           if (def_stmt
+              && gimple_bb (def_stmt)
              && flow_bb_inside_loop_p (loop, gimple_bb (def_stmt))
               && (is_gimple_assign (def_stmt)
                   || is_gimple_call (def_stmt)