X-Git-Url: http://git.sourceforge.jp/view?a=blobdiff_plain;f=gcc%2Ftree-ssa-loop-niter.c;h=15ea06b8b9bddf1918e02ea2a491ecad2f5e799c;hb=8899f79dd96b4323c6dad02242327d3e4edc01bd;hp=cf2f4556395b56fe84705a4b7c500854d8851757;hpb=8767ae9cc8f2181b37bb932cac7b4561de8cc5a2;p=pf3gnuchains%2Fgcc-fork.git diff --git a/gcc/tree-ssa-loop-niter.c b/gcc/tree-ssa-loop-niter.c index cf2f4556395..15ea06b8b9b 100644 --- a/gcc/tree-ssa-loop-niter.c +++ b/gcc/tree-ssa-loop-niter.c @@ -1,5 +1,5 @@ /* 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. @@ -762,8 +762,7 @@ number_of_iterations_lt_to_ne (tree type, affine_iv *iv0, affine_iv *iv1, 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, @@ -788,10 +787,9 @@ number_of_iterations_lt_to_ne (tree type, affine_iv *iv0, affine_iv *iv1, 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, @@ -1166,16 +1164,13 @@ number_of_iterations_le (tree type, affine_iv *iv0, affine_iv *iv1, 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)); @@ -1281,13 +1276,14 @@ number_of_iterations_cond (struct loop *loop, 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; } @@ -2294,7 +2290,10 @@ find_loop_niter_by_eval (struct loop *loop, edge *exit) /* 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) {