aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-loop-ivopts.c
diff options
context:
space:
mode:
authorAndrew Pinski <andrew_pinski@playstation.sony.com>2008-03-11 09:36:51 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2008-03-11 09:36:51 +0000
commit1ffe34d9f7823398e9937858cfdfbbd33e2d9130 (patch)
treef1231d387b8e29a423766fa3401b01369f01515b /gcc/tree-ssa-loop-ivopts.c
parent7f2ad78b6dbee7d3124ba5fb4f953a3c5e22abde (diff)
downloadgcc-1ffe34d9f7823398e9937858cfdfbbd33e2d9130.zip
gcc-1ffe34d9f7823398e9937858cfdfbbd33e2d9130.tar.gz
gcc-1ffe34d9f7823398e9937858cfdfbbd33e2d9130.tar.bz2
re PR tree-optimization/31358 (IV-OPTs produces a weird MEM_REF)
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. Co-Authored-By: Richard Guenther <rguenther@suse.de> From-SVN: r133102
Diffstat (limited to 'gcc/tree-ssa-loop-ivopts.c')
-rw-r--r--gcc/tree-ssa-loop-ivopts.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c
index 02fe707f..9b406ce 100644
--- a/gcc/tree-ssa-loop-ivopts.c
+++ b/gcc/tree-ssa-loop-ivopts.c
@@ -914,7 +914,12 @@ find_bivs (struct ivopts_data *data)
type = TREE_TYPE (PHI_RESULT (phi));
base = fold_convert (type, base);
if (step)
- step = fold_convert (type, step);
+ {
+ if (POINTER_TYPE_P (type))
+ step = fold_convert (sizetype, step);
+ else
+ step = fold_convert (type, step);
+ }
set_iv (data, PHI_RESULT (phi), base, step);
found = true;
@@ -2040,7 +2045,9 @@ add_candidate_1 (struct ivopts_data *data,
{
orig_type = TREE_TYPE (base);
type = generic_type_for (orig_type);
- if (type != orig_type)
+ /* Don't convert the base to the generic type for pointers as the generic
+ type is an integer type with the same size as the pointer type. */
+ if (type != orig_type && !POINTER_TYPE_P (orig_type))
{
base = fold_convert (type, base);
step = fold_convert (type, step);
@@ -2237,13 +2244,17 @@ add_iv_value_candidates (struct ivopts_data *data,
{
unsigned HOST_WIDE_INT offset;
tree base;
+ tree basetype;
add_candidate (data, iv->base, iv->step, false, use);
/* The same, but with initial value zero. Make such variable important,
since it is generic enough so that possibly many uses may be based
on it. */
- add_candidate (data, build_int_cst (TREE_TYPE (iv->base), 0),
+ basetype = TREE_TYPE (iv->base);
+ if (POINTER_TYPE_P (basetype))
+ basetype = sizetype;
+ add_candidate (data, build_int_cst (basetype, 0),
iv->step, true, use);
/* Third, try removing the constant offset. */
@@ -3671,10 +3682,13 @@ cand_value_at (struct loop *loop, struct iv_cand *cand, tree at, tree niter,
aff_tree step, delta, nit;
struct iv *iv = cand->iv;
tree type = TREE_TYPE (iv->base);
+ tree steptype = type;
+ if (POINTER_TYPE_P (type))
+ steptype = sizetype;
- tree_to_aff_combination (iv->step, type, &step);
+ tree_to_aff_combination (iv->step, steptype, &step);
tree_to_aff_combination (niter, TREE_TYPE (niter), &nit);
- aff_combination_convert (&nit, type);
+ aff_combination_convert (&nit, steptype);
aff_combination_mult (&nit, &step, &delta);
if (stmt_after_increment (loop, cand, at))
aff_combination_add (&delta, &step);