diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 715e42314c8..73cc1e46367 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,13 @@ +2007-07-30 Andrew Pinski + + PR tree-opt/32527 + * tree-affine.h (aff_tree): The type of rest is sizetype for types + of pointers. + * tree-affine.c (aff_combination_scale): If type is a pointer type, + use sizetype for rest. + (aff_combination_add_elt): Likewise. Don't specialize pointer types. + (aff_combination_convert): Don't convert rest for pointer types. + 2007-07-28 Daniel Berlin * Makefile.in (tree-ssa-alias.o): Add alloc-pool.h diff --git a/gcc/tree-affine.c b/gcc/tree-affine.c index 972d4423f70..75281884f7f 100644 --- a/gcc/tree-affine.c +++ b/gcc/tree-affine.c @@ -110,6 +110,9 @@ aff_combination_scale (aff_tree *comb, double_int scale) if (comb->rest) { + tree type = comb->type; + if (POINTER_TYPE_P (type)) + type = sizetype; if (comb->n < MAX_AFF_ELTS) { comb->elts[comb->n].coef = scale; @@ -118,8 +121,8 @@ aff_combination_scale (aff_tree *comb, double_int scale) comb->n++; } else - comb->rest = fold_build2 (MULT_EXPR, comb->type, comb->rest, - double_int_to_tree (comb->type, scale)); + comb->rest = fold_build2 (MULT_EXPR, type, comb->rest, + double_int_to_tree (type, scale)); } } @@ -181,14 +184,8 @@ aff_combination_add_elt (aff_tree *comb, tree elt, double_int scale) double_int_to_tree (type, scale)); if (comb->rest) - { - if (POINTER_TYPE_P (comb->type)) - comb->rest = fold_build2 (POINTER_PLUS_EXPR, comb->type, - comb->rest, elt); - else - comb->rest = fold_build2 (PLUS_EXPR, comb->type, comb->rest, - elt); - } + comb->rest = fold_build2 (PLUS_EXPR, type, comb->rest, + elt); else comb->rest = elt; } @@ -231,7 +228,7 @@ aff_combination_convert (aff_tree *comb, tree type) } comb->type = type; - if (comb->rest) + if (comb->rest && !POINTER_TYPE_P (type)) comb->rest = fold_convert (type, comb->rest); if (TYPE_PRECISION (type) == TYPE_PRECISION (comb_type)) diff --git a/gcc/tree-affine.h b/gcc/tree-affine.h index 9bcfa5e1f82..5da34bead9a 100644 --- a/gcc/tree-affine.h +++ b/gcc/tree-affine.h @@ -53,7 +53,8 @@ typedef struct affine_tree_combination struct aff_comb_elt elts[MAX_AFF_ELTS]; /* Remainder of the expression. Usually NULL, used only if there are more - than MAX_AFF_ELTS elements. Type of REST must be TYPE. */ + than MAX_AFF_ELTS elements. Type of REST will be either sizetype for + TYPE of POINTER_TYPEs or TYPE. */ tree rest; } aff_tree;