summaryrefslogtreecommitdiff
path: root/gcc/tree-affine.c
diff options
context:
space:
mode:
authorpinskia <pinskia@138bc75d-0d04-0410-961f-82ee72b054a4>2007-06-28 19:03:49 +0000
committerpinskia <pinskia@138bc75d-0d04-0410-961f-82ee72b054a4>2007-06-28 19:03:49 +0000
commit00de526b9e357aa3ec562116323b656280e91a7d (patch)
tree1491da5dec11ddc8e18a3642e00a9602e8072c1a /gcc/tree-affine.c
parentbab22e5cf8193bf4b12b586a834229205e5202c4 (diff)
downloadgcc-00de526b9e357aa3ec562116323b656280e91a7d.tar.gz
2007-06-28 Andrew Pinski <andrew_pinski@playstation.sony.com>
PR tree-opt/32417 * tree-affine.c (aff_combination_add_elt): Handle pointer addition specially. 2007-06-28 Andrew Pinski <andrew_pinski@playstation.sony.com> PR tree-opt/32417 * gfortran.fortran-torture/compile/pr32417.f90: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@126082 138bc75d-0d04-0410-961f-82ee72b054a4
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 de4cf4ad59f..ec2ad8f1389 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;
}