summaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-loop-manip.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/tree-ssa-loop-manip.c')
-rw-r--r--gcc/tree-ssa-loop-manip.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/gcc/tree-ssa-loop-manip.c b/gcc/tree-ssa-loop-manip.c
index a1d06911d6b..3354fdea6df 100644
--- a/gcc/tree-ssa-loop-manip.c
+++ b/gcc/tree-ssa-loop-manip.c
@@ -96,7 +96,13 @@ create_iv (tree base, tree step, tree var, struct loop *loop,
}
}
}
-
+ if (POINTER_TYPE_P (TREE_TYPE (base)))
+ {
+ step = fold_convert (sizetype, step);
+ if (incr_op == MINUS_EXPR)
+ step = fold_build1 (NEGATE_EXPR, sizetype, step);
+ incr_op = POINTER_PLUS_EXPR;
+ }
/* Gimplify the step if necessary. We put the computations in front of the
loop (i.e. the step should be loop invariant). */
step = force_gimple_operand (step, &stmts, true, var);