summaryrefslogtreecommitdiff
path: root/gcc/tree-affine.c
diff options
context:
space:
mode:
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2008-03-11 09:36:51 +0000
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2008-03-11 09:36:51 +0000
commit06240723d1ac2b9ef1c066c233ce95171518daa3 (patch)
treef1231d387b8e29a423766fa3401b01369f01515b /gcc/tree-affine.c
parentfe33e022a6d884dc9688bcb45b4a288e2f5b20ec (diff)
downloadgcc-06240723d1ac2b9ef1c066c233ce95171518daa3.tar.gz
2008-03-11 Andrew Pinski <andrew_pinski@playstation.sony.com>
Richard Guenther <rguenther@suse.de> PR tree-optimization/31358 * tree-ssa-loop-manip.c (create_iv): Call force_gimple_operand for the step with a NULL_TREE. * tree-ssa-loop-ivopts.c (find_bivs): Convert the step to sizetype if type is a pointer type. (add_candidate_1): Don't convert the base and step to the generic type if the orginal type is a pointer type. (add_iv_value_candidates): Use sizetype for the step if type is a pointer type. (cand_value_at): Likewise. * tree-ssa-address.c (add_to_parts): Use POINTER_PLUS_EXPR for pointer types. * tree-affine.c (tree_to_aff_combination <POINTER_PLUS_EXPR>): Don't convert the tem affine to the type. (add_elt_to_tree): Use sizetype for the step if a pointer. Use POINTER_PLUS_EXPR for pointers. (aff_combination_to_tree): Use sizetype for the step if a pointer. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@133102 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-affine.c')
-rw-r--r--gcc/tree-affine.c37
1 files changed, 28 insertions, 9 deletions
diff --git a/gcc/tree-affine.c b/gcc/tree-affine.c
index b6c47d60618..3a4d897b2d9 100644
--- a/gcc/tree-affine.c
+++ b/gcc/tree-affine.c
@@ -279,7 +279,6 @@ tree_to_aff_combination (tree expr, tree type, aff_tree *comb)
case POINTER_PLUS_EXPR:
tree_to_aff_combination (TREE_OPERAND (expr, 0), type, comb);
tree_to_aff_combination (TREE_OPERAND (expr, 1), sizetype, &tmp);
- aff_combination_convert (&tmp, type);
aff_combination_add (comb, &tmp);
return;
@@ -350,29 +349,40 @@ add_elt_to_tree (tree expr, tree type, tree elt, double_int scale,
aff_tree *comb)
{
enum tree_code code;
+ tree type1 = type;
+ if (POINTER_TYPE_P (type))
+ type1 = sizetype;
scale = double_int_ext_for_comb (scale, comb);
- elt = fold_convert (type, elt);
+ elt = fold_convert (type1, elt);
if (double_int_one_p (scale))
{
if (!expr)
- return elt;
+ return fold_convert (type, elt);
+ if (POINTER_TYPE_P (type))
+ return fold_build2 (POINTER_PLUS_EXPR, type, expr, elt);
return fold_build2 (PLUS_EXPR, type, expr, elt);
}
if (double_int_minus_one_p (scale))
{
if (!expr)
- return fold_build1 (NEGATE_EXPR, type, elt);
+ return fold_convert (type, fold_build1 (NEGATE_EXPR, type1, elt));
+ if (POINTER_TYPE_P (type))
+ {
+ elt = fold_build1 (NEGATE_EXPR, type1, elt);
+ return fold_build2 (POINTER_PLUS_EXPR, type, expr, elt);
+ }
return fold_build2 (MINUS_EXPR, type, expr, elt);
}
if (!expr)
- return fold_build2 (MULT_EXPR, type, elt,
- double_int_to_tree (type, scale));
+ return fold_convert (type,
+ fold_build2 (MULT_EXPR, type1, elt,
+ double_int_to_tree (type1, scale)));
if (double_int_negative_p (scale))
{
@@ -382,8 +392,14 @@ add_elt_to_tree (tree expr, tree type, tree elt, double_int scale,
else
code = PLUS_EXPR;
- elt = fold_build2 (MULT_EXPR, type, elt,
- double_int_to_tree (type, scale));
+ elt = fold_build2 (MULT_EXPR, type1, elt,
+ double_int_to_tree (type1, scale));
+ if (POINTER_TYPE_P (type))
+ {
+ if (code == MINUS_EXPR)
+ elt = fold_build1 (NEGATE_EXPR, type1, elt);
+ return fold_build2 (POINTER_PLUS_EXPR, type, expr, elt);
+ }
return fold_build2 (code, type, expr, elt);
}
@@ -396,6 +412,9 @@ aff_combination_to_tree (aff_tree *comb)
tree expr = comb->rest;
unsigned i;
double_int off, sgn;
+ tree type1 = type;
+ if (POINTER_TYPE_P (type))
+ type1 = sizetype;
gcc_assert (comb->n == MAX_AFF_ELTS || comb->rest == NULL_TREE);
@@ -415,7 +434,7 @@ aff_combination_to_tree (aff_tree *comb)
off = comb->offset;
sgn = double_int_one;
}
- return add_elt_to_tree (expr, type, double_int_to_tree (type, off), sgn,
+ return add_elt_to_tree (expr, type, double_int_to_tree (type1, off), sgn,
comb);
}