From 00de526b9e357aa3ec562116323b656280e91a7d Mon Sep 17 00:00:00 2001 From: pinskia Date: Thu, 28 Jun 2007 19:03:49 +0000 Subject: 2007-06-28 Andrew Pinski PR tree-opt/32417 * tree-affine.c (aff_combination_add_elt): Handle pointer addition specially. 2007-06-28 Andrew Pinski 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 --- gcc/tree-affine.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'gcc/tree-affine.c') 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; } -- cgit v1.2.1