aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-affine.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/tree-affine.c')
-rw-r--r--gcc/tree-affine.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/gcc/tree-affine.c b/gcc/tree-affine.c
index de4cf4a..ec2ad8f 100644
--- a/gcc/tree-affine.c
+++ b/gcc/tree-affine.c
@@ -130,6 +130,7 @@ void
aff_combination_add_elt (aff_tree *comb, tree elt, double_int scale)
{
unsigned i;
+ tree type;
scale = double_int_ext_for_comb (scale, comb);
if (double_int_zero_p (scale))
@@ -169,15 +170,26 @@ aff_combination_add_elt (aff_tree *comb, tree elt, double_int scale)
return;
}
+ type = comb->type;
+ if (POINTER_TYPE_P (type))
+ type = sizetype;
+
if (double_int_one_p (scale))
- elt = fold_convert (comb->type, elt);
+ elt = fold_convert (type, elt);
else
- elt = fold_build2 (MULT_EXPR, comb->type,
- fold_convert (comb->type, elt),
- double_int_to_tree (comb->type, scale));
+ elt = fold_build2 (MULT_EXPR, type,
+ fold_convert (type, elt),
+ double_int_to_tree (type, scale));
if (comb->rest)
- comb->rest = fold_build2 (PLUS_EXPR, comb->type, comb->rest, elt);
+ {
+ 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);
+ }
else
comb->rest = elt;
}