OSDN Git Service

2009-05-29 Kai Tietz <kai.tietz@onevision.com>
[pf3gnuchains/gcc-fork.git] / gcc / tree-vect-loop-manip.c
index 0edcccb..3d7f593 100644 (file)
@@ -1593,7 +1593,8 @@ vect_update_ivs_after_vectorizer (loop_vec_info loop_vinfo, tree niters,
       tree access_fn = NULL;
       tree evolution_part;
       tree init_expr;
-      tree step_expr;
+      tree step_expr, off;
+      tree type;
       tree var, ni, ni_name;
       gimple_stmt_iterator last_gsi;
 
@@ -1623,6 +1624,11 @@ vect_update_ivs_after_vectorizer (loop_vec_info loop_vinfo, tree niters,
 
       access_fn = analyze_scalar_evolution (loop, PHI_RESULT (phi)); 
       gcc_assert (access_fn);
+      /* We can end up with an access_fn like
+           (short int) {(short unsigned int) i_49, +, 1}_1
+        for further analysis we need to strip the outer cast but we
+        need to preserve the original type.  */
+      type = TREE_TYPE (access_fn);
       STRIP_NOPS (access_fn);
       evolution_part =
         unshare_expr (evolution_part_in_loop_num (access_fn, loop->num));
@@ -1635,22 +1641,19 @@ vect_update_ivs_after_vectorizer (loop_vec_info loop_vinfo, tree niters,
       step_expr = evolution_part;
       init_expr = unshare_expr (initial_condition_in_loop_num (access_fn, 
                                                               loop->num));
+      init_expr = fold_convert (type, init_expr);
 
+      off = fold_build2 (MULT_EXPR, TREE_TYPE (step_expr),
+                        fold_convert (TREE_TYPE (step_expr), niters),
+                        step_expr);
       if (POINTER_TYPE_P (TREE_TYPE (init_expr)))
        ni = fold_build2 (POINTER_PLUS_EXPR, TREE_TYPE (init_expr), 
-                         init_expr, 
-                         fold_convert (sizetype, 
-                                       fold_build2 (MULT_EXPR, TREE_TYPE (niters),
-                                                    niters, step_expr)));
+                         init_expr,
+                         fold_convert (sizetype, off));
       else
        ni = fold_build2 (PLUS_EXPR, TREE_TYPE (init_expr),
-                         fold_build2 (MULT_EXPR, TREE_TYPE (init_expr),
-                                      fold_convert (TREE_TYPE (init_expr),
-                                                    niters),
-                                      step_expr),
-                         init_expr);
-
-
+                         init_expr,
+                         fold_convert (TREE_TYPE (init_expr), off));
 
       var = create_tmp_var (TREE_TYPE (init_expr), "tmp");
       add_referenced_var (var);
@@ -1926,7 +1929,8 @@ vect_update_init_of_dr (struct data_reference *dr, tree niters)
   niters = fold_build2 (MULT_EXPR, sizetype,
                        fold_convert (sizetype, niters),
                        fold_convert (sizetype, DR_STEP (dr)));
-  offset = fold_build2 (PLUS_EXPR, sizetype, offset, niters);
+  offset = fold_build2 (PLUS_EXPR, sizetype,
+                       fold_convert (sizetype, offset), niters);
   DR_OFFSET (dr) = offset;
 }
 
@@ -2286,7 +2290,7 @@ vect_create_cond_for_alias_checks (loop_vec_info loop_vinfo,
       else
        *cond_expr = part_cond_expr;
     }
-    if (vect_print_dump_info (REPORT_VECTORIZED_LOOPS))
+    if (vect_print_dump_info (REPORT_VECTORIZED_LOCATIONS))
       fprintf (vect_dump, "created %u versioning for alias checks.\n",
                VEC_length (ddr_p, may_alias_ddrs));