OSDN Git Service

PR c++/47132
[pf3gnuchains/gcc-fork.git] / gcc / tree-vect-patterns.c
index 5ba2fa5..c241ee0 100644 (file)
@@ -36,7 +36,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "tree-data-ref.h"
 #include "tree-vectorizer.h"
 #include "recog.h"
-#include "toplev.h"
+#include "diagnostic-core.h"
 
 /* Function prototypes */
 static void vect_pattern_recog_1
@@ -179,7 +179,7 @@ vect_recog_dot_prod_pattern (gimple last_stmt, tree *type_in, tree *type_out)
   tree prod_type;
   loop_vec_info loop_info = STMT_VINFO_LOOP_VINFO (stmt_vinfo);
   struct loop *loop = LOOP_VINFO_LOOP (loop_info);
-  tree var, rhs;
+  tree var;
 
   if (!is_gimple_assign (last_stmt))
     return NULL;
@@ -254,6 +254,11 @@ vect_recog_dot_prod_pattern (gimple last_stmt, tree *type_in, tree *type_out)
 
   prod_type = half_type;
   stmt = SSA_NAME_DEF_STMT (oprnd0);
+
+  /* It could not be the dot_prod pattern if the stmt is outside the loop.  */
+  if (!gimple_bb (stmt) || !flow_bb_inside_loop_p (loop, gimple_bb (stmt)))
+    return NULL;
+
   /* FORNOW.  Can continue analyzing the def-use chain when this stmt in a phi
      inside the loop (in case we are analyzing an outer-loop).  */
   if (!is_gimple_assign (stmt))
@@ -306,8 +311,8 @@ vect_recog_dot_prod_pattern (gimple last_stmt, tree *type_in, tree *type_out)
 
   /* Pattern detected. Create a stmt to be used to replace the pattern: */
   var = vect_recog_temp_ssa_var (type, NULL);
-  rhs =        build3 (DOT_PROD_EXPR, type, oprnd00, oprnd01, oprnd1),
-  pattern_stmt = gimple_build_assign (var, rhs);
+  pattern_stmt = gimple_build_assign_with_ops3 (DOT_PROD_EXPR, var,
+                                               oprnd00, oprnd01, oprnd1);
 
   if (vect_print_dump_info (REPORT_DETAILS))
     {
@@ -407,6 +412,7 @@ vect_recog_widen_mult_pattern (gimple last_stmt,
   vectype = get_vectype_for_scalar_type (half_type0);
   vectype_out = get_vectype_for_scalar_type (type);
   if (!vectype
+      || !vectype_out
       || !supportable_widening_operation (WIDEN_MULT_EXPR, last_stmt,
                                          vectype_out, vectype,
                                          &dummy, &dummy, &dummy_code,
@@ -466,6 +472,9 @@ vect_recog_pow_pattern (gimple last_stmt, tree *type_in, tree *type_out)
     return NULL;
 
   fn = gimple_call_fndecl (last_stmt);
+  if (fn == NULL_TREE || DECL_BUILT_IN_CLASS (fn) != BUILT_IN_NORMAL)
+   return NULL;
+
   switch (DECL_FUNCTION_CODE (fn))
     {
     case BUILT_IN_POWIF:
@@ -714,8 +723,7 @@ vect_pattern_recog_1 (
       optab = optab_for_tree_code (code, type_in, optab_default);
       vec_mode = TYPE_MODE (type_in);
       if (!optab
-          || (icode = optab_handler (optab, vec_mode)->insn_code) ==
-              CODE_FOR_nothing
+          || (icode = optab_handler (optab, vec_mode)) == CODE_FOR_nothing
           || (insn_data[icode].operand[0].mode != TYPE_MODE (type_out)))
        return;
     }
@@ -741,9 +749,7 @@ vect_pattern_recog_1 (
 
   /* Patterns cannot be vectorized using SLP, because they change the order of
      computation.  */
-  for (i = 0; VEC_iterate (gimple, LOOP_VINFO_REDUCTIONS (loop_vinfo), i,
-                           next);
-       i++)
+  FOR_EACH_VEC_ELT (gimple, LOOP_VINFO_REDUCTIONS (loop_vinfo), i, next)
     if (next == stmt)
       VEC_ordered_remove (gimple, LOOP_VINFO_REDUCTIONS (loop_vinfo), i); 
 }