[PATCH] Fix gcc.target/i386/pr37101.c type error

Richard Guenther rguenther@suse.de
Tue Apr 28 13:39:00 GMT 2009


This makes sure to use the correct type for vector pointer increments.

Will apply after bootstrapping and testing on x86_64-unknown-linux-gnu.

Richard.

2009-04-28  Richard Guenther  <rguenther@suse.de>

	* tree-vect-loop.c (get_initial_def_for_induction): Use
	correct types for pointer increment.

Index: gcc/tree-vect-loop.c
===================================================================
*** gcc/tree-vect-loop.c	(revision 146887)
--- gcc/tree-vect-loop.c	(working copy)
*************** get_initial_def_for_induction (gimple iv
*** 2223,2228 ****
--- 2223,2229 ----
    tree loop_arg;
    gimple_stmt_iterator si;
    basic_block bb = gimple_bb (iv_phi);
+   tree stepvectype;
  
    vectype = get_vectype_for_scalar_type (scalar_type);
    gcc_assert (vectype);
*************** get_initial_def_for_induction (gimple iv
*** 2235,2242 ****
    /* Find the first insertion point in the BB.  */
    si = gsi_after_labels (bb);
  
!   if (INTEGRAL_TYPE_P (scalar_type) || POINTER_TYPE_P (scalar_type))
      step_expr = build_int_cst (scalar_type, 0);
    else
      step_expr = build_real (scalar_type, dconst0);
  
--- 2236,2245 ----
    /* Find the first insertion point in the BB.  */
    si = gsi_after_labels (bb);
  
!   if (INTEGRAL_TYPE_P (scalar_type))
      step_expr = build_int_cst (scalar_type, 0);
+   else if (POINTER_TYPE_P (scalar_type))
+     step_expr = build_int_cst (sizetype, 0);
    else
      step_expr = build_real (scalar_type, dconst0);
  
*************** get_initial_def_for_induction (gimple iv
*** 2320,2335 ****
      {
        /* iv_loop is the loop to be vectorized. Generate:
  	  vec_step = [VF*S, VF*S, VF*S, VF*S]  */
!       expr = build_int_cst (scalar_type, vf);
!       new_name = fold_build2 (MULT_EXPR, scalar_type, expr, step_expr);
      }
  
    t = NULL_TREE;
    for (i = 0; i < nunits; i++)
      t = tree_cons (NULL_TREE, unshare_expr (new_name), t);
    gcc_assert (CONSTANT_CLASS_P (new_name));
!   vec = build_vector (vectype, t);
!   vec_step = vect_init_vector (iv_phi, vec, vectype, NULL);
  
  
    /* Create the following def-use cycle:
--- 2323,2341 ----
      {
        /* iv_loop is the loop to be vectorized. Generate:
  	  vec_step = [VF*S, VF*S, VF*S, VF*S]  */
!       expr = build_int_cst (TREE_TYPE (step_expr), vf);
!       new_name = fold_build2 (MULT_EXPR, TREE_TYPE (step_expr),
! 			      expr, step_expr);
      }
  
    t = NULL_TREE;
    for (i = 0; i < nunits; i++)
      t = tree_cons (NULL_TREE, unshare_expr (new_name), t);
    gcc_assert (CONSTANT_CLASS_P (new_name));
!   stepvectype = get_vectype_for_scalar_type (TREE_TYPE (new_name));
!   gcc_assert (stepvectype);
!   vec = build_vector (stepvectype, t);
!   vec_step = vect_init_vector (iv_phi, vec, stepvectype, NULL);
  
  
    /* Create the following def-use cycle:
*************** get_initial_def_for_induction (gimple iv
*** 2377,2390 ****
        gcc_assert (!nested_in_vect_loop);
  
        /* Create the vector that holds the step of the induction.  */
!       expr = build_int_cst (scalar_type, nunits);
!       new_name = fold_build2 (MULT_EXPR, scalar_type, expr, step_expr);
        t = NULL_TREE;
        for (i = 0; i < nunits; i++)
  	t = tree_cons (NULL_TREE, unshare_expr (new_name), t);
        gcc_assert (CONSTANT_CLASS_P (new_name));
!       vec = build_vector (vectype, t);
!       vec_step = vect_init_vector (iv_phi, vec, vectype, NULL);
  
        vec_def = induc_def;
        prev_stmt_vinfo = vinfo_for_stmt (induction_phi);
--- 2383,2397 ----
        gcc_assert (!nested_in_vect_loop);
  
        /* Create the vector that holds the step of the induction.  */
!       expr = build_int_cst (TREE_TYPE (step_expr), nunits);
!       new_name = fold_build2 (MULT_EXPR, TREE_TYPE (step_expr),
! 			      expr, step_expr);
        t = NULL_TREE;
        for (i = 0; i < nunits; i++)
  	t = tree_cons (NULL_TREE, unshare_expr (new_name), t);
        gcc_assert (CONSTANT_CLASS_P (new_name));
!       vec = build_vector (stepvectype, t);
!       vec_step = vect_init_vector (iv_phi, vec, stepvectype, NULL);
  
        vec_def = induc_def;
        prev_stmt_vinfo = vinfo_for_stmt (induction_phi);



More information about the Gcc-patches mailing list