/* Functions to determine/estimate number of iterations of a loop.
- Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010
+ Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
Free Software Foundation, Inc.
This file is part of GCC.
else if (POINTER_TYPE_P (type))
noloop = fold_build2 (GT_EXPR, boolean_type_node,
iv0->base,
- fold_build2 (POINTER_PLUS_EXPR, type,
- iv1->base, tmod));
+ fold_build_pointer_plus (iv1->base, tmod));
else
noloop = fold_build2 (GT_EXPR, boolean_type_node,
iv0->base,
noloop = boolean_false_node;
else if (POINTER_TYPE_P (type))
noloop = fold_build2 (GT_EXPR, boolean_type_node,
- fold_build2 (POINTER_PLUS_EXPR, type,
- iv0->base,
- fold_build1 (NEGATE_EXPR,
- type1, tmod)),
+ fold_build_pointer_plus (iv0->base,
+ fold_build1 (NEGATE_EXPR,
+ type1, tmod)),
iv1->base);
else
noloop = fold_build2 (GT_EXPR, boolean_type_node,
if (integer_nonzerop (iv0->step))
{
if (POINTER_TYPE_P (type))
- iv1->base = fold_build2 (POINTER_PLUS_EXPR, type, iv1->base,
- build_int_cst (type1, 1));
+ iv1->base = fold_build_pointer_plus_hwi (iv1->base, 1);
else
iv1->base = fold_build2 (PLUS_EXPR, type1, iv1->base,
build_int_cst (type1, 1));
}
else if (POINTER_TYPE_P (type))
- iv0->base = fold_build2 (POINTER_PLUS_EXPR, type, iv0->base,
- fold_build1 (NEGATE_EXPR, type1,
- build_int_cst (type1, 1)));
+ iv0->base = fold_build_pointer_plus_hwi (iv0->base, -1);
else
iv0->base = fold_build2 (MINUS_EXPR, type1,
iv0->base, build_int_cst (type1, 1));
practice, but it is simple enough to manage. */
if (!integer_zerop (iv0->step) && !integer_zerop (iv1->step))
{
+ tree step_type = POINTER_TYPE_P (type) ? sizetype : type;
if (code != NE_EXPR)
return false;
- iv0->step = fold_binary_to_constant (MINUS_EXPR, type,
+ iv0->step = fold_binary_to_constant (MINUS_EXPR, step_type,
iv0->step, iv1->step);
iv0->no_overflow = false;
- iv1->step = build_int_cst (type, 0);
+ iv1->step = build_int_cst (step_type, 0);
iv1->no_overflow = true;
}
/* Loops with multiple exits are expensive to handle and less important. */
if (!flag_expensive_optimizations
&& VEC_length (edge, exits) > 1)
- return chrec_dont_know;
+ {
+ VEC_free (edge, heap, exits);
+ return chrec_dont_know;
+ }
FOR_EACH_VEC_ELT (edge, exits, i, ex)
{