This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH, approved] Fix types in chrec / ivopts


This patch to correct mismatched tree types detected by instrumenting
was bootstrapped and regtested on x86_64-linux-gnu and approved by
Roger in a separate thread.  It will be applied tomorrow if nobody
objects.

Thanks,
Richard.


2005-06-01  Richard Guenther  <rguenth@gcc.gnu.org>

	* tree-chrec.c (chrec_fold_plus_1): Ensure we build
	binary operations with the correct types.
	* tree-ssa-loo-ivopts.c (idx_find_step): Use sizetype
	for all computation.


Index: tree-chrec.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-chrec.c,v
retrieving revision 2.17
diff -c -3 -p -r2.17 tree-chrec.c
*** tree-chrec.c	1 Jun 2005 02:50:54 -0000	2.17
--- tree-chrec.c	1 Jun 2005 12:48:10 -0000
*************** chrec_fold_plus_1 (enum tree_code code, 
*** 293,299 ****
  		&& size < PARAM_VALUE (PARAM_SCEV_MAX_EXPR_SIZE))
  	      return build2 (code, type, op0, op1);
  	    else if (size < PARAM_VALUE (PARAM_SCEV_MAX_EXPR_SIZE))
! 	      return fold_build2 (code, type, op0, op1);
  	    else
  	      return chrec_dont_know;
  	  }
--- 293,301 ----
  		&& size < PARAM_VALUE (PARAM_SCEV_MAX_EXPR_SIZE))
  	      return build2 (code, type, op0, op1);
  	    else if (size < PARAM_VALUE (PARAM_SCEV_MAX_EXPR_SIZE))
! 	      return fold_build2 (code, type,
! 				  fold_convert (type, op0),
! 				  fold_convert (type, op1));
  	    else
  	      return chrec_dont_know;
  	  }
Index: tree-ssa-loop-ivopts.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-loop-ivopts.c,v
retrieving revision 2.73
diff -c -3 -p -r2.73 tree-ssa-loop-ivopts.c
*** tree-ssa-loop-ivopts.c	26 May 2005 18:14:48 -0000	2.73
--- tree-ssa-loop-ivopts.c	1 Jun 2005 15:32:07 -0000
*************** idx_find_step (tree base, tree *idx, voi
*** 1389,1395 ****
  {
    struct ifs_ivopts_data *dta = data;
    struct iv *iv;
!   tree step, type, iv_type, iv_step, lbound, off;
    struct loop *loop = dta->ivopts_data->current_loop;
  
    if (TREE_CODE (base) == MISALIGNED_INDIRECT_REF
--- 1389,1395 ----
  {
    struct ifs_ivopts_data *dta = data;
    struct iv *iv;
!   tree step, iv_step, lbound, off;
    struct loop *loop = dta->ivopts_data->current_loop;
  
    if (TREE_CODE (base) == MISALIGNED_INDIRECT_REF
*************** idx_find_step (tree base, tree *idx, voi
*** 1430,1437 ****
    if (!iv->step)
      return true;
  
-   iv_type = TREE_TYPE (iv->base);
-   type = build_pointer_type (TREE_TYPE (base));
    if (TREE_CODE (base) == ARRAY_REF)
      {
        step = array_ref_element_size (base);
--- 1430,1435 ----
*************** idx_find_step (tree base, tree *idx, voi
*** 1442,1454 ****
      }
    else
      /* The step for pointer arithmetics already is 1 byte.  */
!     step = build_int_cst (type, 1);
  
!   if (TYPE_PRECISION (iv_type) < TYPE_PRECISION (type))
      iv_step = can_count_iv_in_wider_type (dta->ivopts_data->current_loop,
! 					  type, iv->base, iv->step, dta->stmt);
    else
!     iv_step = fold_convert (iv_type, iv->step);
  
    if (!iv_step)
      {
--- 1440,1452 ----
      }
    else
      /* The step for pointer arithmetics already is 1 byte.  */
!     step = build_int_cst (sizetype, 1);
  
!   if (TYPE_PRECISION (TREE_TYPE (iv->base)) < TYPE_PRECISION (sizetype))
      iv_step = can_count_iv_in_wider_type (dta->ivopts_data->current_loop,
! 					  sizetype, iv->base, iv->step, dta->stmt);
    else
!     iv_step = fold_convert (sizetype, iv->step);
  
    if (!iv_step)
      {
*************** idx_find_step (tree base, tree *idx, voi
*** 1456,1467 ****
        return false;
      }
  
!   step = fold_build2 (MULT_EXPR, type, step, iv_step);
  
    if (!*dta->step_p)
      *dta->step_p = step;
    else
!     *dta->step_p = fold_build2 (PLUS_EXPR, type, *dta->step_p, step);
  
    return true;
  }
--- 1454,1465 ----
        return false;
      }
  
!   step = fold_build2 (MULT_EXPR, sizetype, step, iv_step);
  
    if (!*dta->step_p)
      *dta->step_p = step;
    else
!     *dta->step_p = fold_build2 (PLUS_EXPR, sizetype, *dta->step_p, step);
  
    return true;
  }

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]