Message ID | 1312261287-13124-2-git-send-email-sebpop@gmail.com |
---|---|
State | New |
Headers | show |
On Tue, 2 Aug 2011, Sebastian Pop wrote: I think that we don't want to canonicalize build_int_cst (..., [01]) to build_{one,zero}_cst. The former is really more descriptive. The build_{one,zero}_cst wrappers were introduced for the fold_convert (type, integer_{one,zero}_node) idiom as fold_convert treats those constants specially and can convert it to any numerical type (such as a complex double). For that idiom the build_{one,zero}_cst is more descriptive if we don't know we always deal with an integer type (in which case we'd use build_int_cst again). Thanks, Richard. > --- > gcc/tree-ssa-loop-niter.c | 32 ++++++++++++++++---------------- > 1 files changed, 16 insertions(+), 16 deletions(-) > > diff --git a/gcc/tree-ssa-loop-niter.c b/gcc/tree-ssa-loop-niter.c > index 4acfc67..2ee3f6e 100644 > --- a/gcc/tree-ssa-loop-niter.c > +++ b/gcc/tree-ssa-loop-niter.c > @@ -101,7 +101,7 @@ split_to_var_and_offset (tree expr, tree *var, mpz_t offset) > break; > > case INTEGER_CST: > - *var = build_int_cst_type (type, 0); > + *var = build_zero_cst (type); > off = tree_to_double_int (expr); > mpz_set_double_int (offset, off, TYPE_UNSIGNED (type)); > break; > @@ -522,7 +522,7 @@ inverse (tree x, tree mask) > } > else > { > - rslt = build_int_cst (type, 1); > + rslt = build_one_cst (type); > for (; ctr; ctr--) > { > rslt = int_const_binop (MULT_EXPR, rslt, x); > @@ -670,7 +670,7 @@ number_of_iterations_ne (tree type, affine_iv *iv, tree final, > - tree_low_cst (bits, 1))); > > d = fold_binary_to_constant (LSHIFT_EXPR, niter_type, > - build_int_cst (niter_type, 1), bits); > + build_one_cst (niter_type), bits); > s = fold_binary_to_constant (RSHIFT_EXPR, niter_type, s, bits); > > if (!exit_must_be_taken) > @@ -679,7 +679,7 @@ number_of_iterations_ne (tree type, affine_iv *iv, tree final, > assumptions for divisibility of c. */ > assumption = fold_build2 (FLOOR_MOD_EXPR, niter_type, c, d); > assumption = fold_build2 (EQ_EXPR, boolean_type_node, > - assumption, build_int_cst (niter_type, 0)); > + assumption, build_zero_cst (niter_type)); > if (!integer_nonzerop (assumption)) > niter->assumptions = fold_build2 (TRUTH_AND_EXPR, boolean_type_node, > niter->assumptions, assumption); > @@ -846,7 +846,7 @@ assert_no_overflow_lt (tree type, affine_iv *iv0, affine_iv *iv1, > } > else > diff = fold_build2 (MINUS_EXPR, niter_type, step, > - build_int_cst (niter_type, 1)); > + build_one_cst (niter_type)); > bound = fold_build2 (MINUS_EXPR, type, > TYPE_MAX_VALUE (type), fold_convert (type, diff)); > assumption = fold_build2 (LE_EXPR, boolean_type_node, > @@ -867,7 +867,7 @@ assert_no_overflow_lt (tree type, affine_iv *iv0, affine_iv *iv1, > } > else > diff = fold_build2 (MINUS_EXPR, niter_type, step, > - build_int_cst (niter_type, 1)); > + build_one_cst (niter_type)); > bound = fold_build2 (PLUS_EXPR, type, > TYPE_MIN_VALUE (type), fold_convert (type, diff)); > assumption = fold_build2 (GE_EXPR, boolean_type_node, > @@ -963,7 +963,7 @@ assert_loop_rolls_lt (tree type, affine_iv *iv0, affine_iv *iv1, > if (integer_nonzerop (iv0->step)) > { > diff = fold_build2 (MINUS_EXPR, type1, > - iv0->step, build_int_cst (type1, 1)); > + iv0->step, build_one_cst (type1)); > > /* We need to know that iv0->base >= MIN + iv0->step - 1. Since > 0 address never belongs to any object, we can assume this for > @@ -985,7 +985,7 @@ assert_loop_rolls_lt (tree type, affine_iv *iv0, affine_iv *iv1, > else > { > diff = fold_build2 (PLUS_EXPR, type1, > - iv1->step, build_int_cst (type1, 1)); > + iv1->step, build_one_cst (type1)); > > if (!POINTER_TYPE_P (type)) > { > @@ -1083,7 +1083,7 @@ number_of_iterations_lt (tree type, affine_iv *iv0, affine_iv *iv1, > { > affine_iv zps; > > - zps.base = build_int_cst (niter_type, 0); > + zps.base = build_zero_cst (niter_type); > zps.step = step; > /* number_of_iterations_lt_to_ne will add assumptions that ensure that > zps does not overflow. */ > @@ -1102,7 +1102,7 @@ number_of_iterations_lt (tree type, affine_iv *iv0, affine_iv *iv1, > assert_loop_rolls_lt (type, iv0, iv1, niter, bnds); > > s = fold_build2 (MINUS_EXPR, niter_type, > - step, build_int_cst (niter_type, 1)); > + step, build_one_cst (niter_type)); > delta = fold_build2 (PLUS_EXPR, niter_type, delta, s); > niter->niter = fold_build2 (FLOOR_DIV_EXPR, niter_type, delta, step); > > @@ -1167,13 +1167,13 @@ number_of_iterations_le (tree type, affine_iv *iv0, affine_iv *iv1, > 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)); > + build_one_cst (type1)); > } > else if (POINTER_TYPE_P (type)) > 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)); > + iv0->base, build_one_cst (type1)); > > bounds_add (bnds, double_int_one, type1); > > @@ -1282,7 +1282,7 @@ number_of_iterations_cond (struct loop *loop, > iv0->step = fold_binary_to_constant (MINUS_EXPR, type, > iv0->step, iv1->step); > iv0->no_overflow = false; > - iv1->step = build_int_cst (type, 0); > + iv1->step = build_zero_cst (type); > iv1->no_overflow = true; > } > > @@ -1305,7 +1305,7 @@ number_of_iterations_cond (struct loop *loop, > /* If the loop exits immediately, there is nothing to do. */ > if (integer_zerop (fold_build2 (code, boolean_type_node, iv0->base, iv1->base))) > { > - niter->niter = build_int_cst (unsigned_type_for (type), 0); > + niter->niter = build_zero_cst (unsigned_type_for (type)); > niter->max = double_int_zero; > return true; > } > @@ -1946,7 +1946,7 @@ find_loop_niter (struct loop *loop, edge *exit) > { > /* We exit in the first iteration through this exit. > We won't find anything better. */ > - niter = build_int_cst (unsigned_type_node, 0); > + niter = build_zero_cst (unsigned_type_node); > *exit = ex; > break; > } > @@ -3017,7 +3017,7 @@ estimate_numbers_of_iterations_loop (struct loop *loop, bool use_undefined_p) > type = TREE_TYPE (niter); > if (TREE_CODE (niter_desc.may_be_zero) != INTEGER_CST) > niter = build3 (COND_EXPR, type, niter_desc.may_be_zero, > - build_int_cst (type, 0), > + build_zero_cst (type), > niter); > record_estimate (loop, niter, niter_desc.max, > last_stmt (ex->src), >
diff --git a/gcc/tree-ssa-loop-niter.c b/gcc/tree-ssa-loop-niter.c index 4acfc67..2ee3f6e 100644 --- a/gcc/tree-ssa-loop-niter.c +++ b/gcc/tree-ssa-loop-niter.c @@ -101,7 +101,7 @@ split_to_var_and_offset (tree expr, tree *var, mpz_t offset) break; case INTEGER_CST: - *var = build_int_cst_type (type, 0); + *var = build_zero_cst (type); off = tree_to_double_int (expr); mpz_set_double_int (offset, off, TYPE_UNSIGNED (type)); break; @@ -522,7 +522,7 @@ inverse (tree x, tree mask) } else { - rslt = build_int_cst (type, 1); + rslt = build_one_cst (type); for (; ctr; ctr--) { rslt = int_const_binop (MULT_EXPR, rslt, x); @@ -670,7 +670,7 @@ number_of_iterations_ne (tree type, affine_iv *iv, tree final, - tree_low_cst (bits, 1))); d = fold_binary_to_constant (LSHIFT_EXPR, niter_type, - build_int_cst (niter_type, 1), bits); + build_one_cst (niter_type), bits); s = fold_binary_to_constant (RSHIFT_EXPR, niter_type, s, bits); if (!exit_must_be_taken) @@ -679,7 +679,7 @@ number_of_iterations_ne (tree type, affine_iv *iv, tree final, assumptions for divisibility of c. */ assumption = fold_build2 (FLOOR_MOD_EXPR, niter_type, c, d); assumption = fold_build2 (EQ_EXPR, boolean_type_node, - assumption, build_int_cst (niter_type, 0)); + assumption, build_zero_cst (niter_type)); if (!integer_nonzerop (assumption)) niter->assumptions = fold_build2 (TRUTH_AND_EXPR, boolean_type_node, niter->assumptions, assumption); @@ -846,7 +846,7 @@ assert_no_overflow_lt (tree type, affine_iv *iv0, affine_iv *iv1, } else diff = fold_build2 (MINUS_EXPR, niter_type, step, - build_int_cst (niter_type, 1)); + build_one_cst (niter_type)); bound = fold_build2 (MINUS_EXPR, type, TYPE_MAX_VALUE (type), fold_convert (type, diff)); assumption = fold_build2 (LE_EXPR, boolean_type_node, @@ -867,7 +867,7 @@ assert_no_overflow_lt (tree type, affine_iv *iv0, affine_iv *iv1, } else diff = fold_build2 (MINUS_EXPR, niter_type, step, - build_int_cst (niter_type, 1)); + build_one_cst (niter_type)); bound = fold_build2 (PLUS_EXPR, type, TYPE_MIN_VALUE (type), fold_convert (type, diff)); assumption = fold_build2 (GE_EXPR, boolean_type_node, @@ -963,7 +963,7 @@ assert_loop_rolls_lt (tree type, affine_iv *iv0, affine_iv *iv1, if (integer_nonzerop (iv0->step)) { diff = fold_build2 (MINUS_EXPR, type1, - iv0->step, build_int_cst (type1, 1)); + iv0->step, build_one_cst (type1)); /* We need to know that iv0->base >= MIN + iv0->step - 1. Since 0 address never belongs to any object, we can assume this for @@ -985,7 +985,7 @@ assert_loop_rolls_lt (tree type, affine_iv *iv0, affine_iv *iv1, else { diff = fold_build2 (PLUS_EXPR, type1, - iv1->step, build_int_cst (type1, 1)); + iv1->step, build_one_cst (type1)); if (!POINTER_TYPE_P (type)) { @@ -1083,7 +1083,7 @@ number_of_iterations_lt (tree type, affine_iv *iv0, affine_iv *iv1, { affine_iv zps; - zps.base = build_int_cst (niter_type, 0); + zps.base = build_zero_cst (niter_type); zps.step = step; /* number_of_iterations_lt_to_ne will add assumptions that ensure that zps does not overflow. */ @@ -1102,7 +1102,7 @@ number_of_iterations_lt (tree type, affine_iv *iv0, affine_iv *iv1, assert_loop_rolls_lt (type, iv0, iv1, niter, bnds); s = fold_build2 (MINUS_EXPR, niter_type, - step, build_int_cst (niter_type, 1)); + step, build_one_cst (niter_type)); delta = fold_build2 (PLUS_EXPR, niter_type, delta, s); niter->niter = fold_build2 (FLOOR_DIV_EXPR, niter_type, delta, step); @@ -1167,13 +1167,13 @@ number_of_iterations_le (tree type, affine_iv *iv0, affine_iv *iv1, 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)); + build_one_cst (type1)); } else if (POINTER_TYPE_P (type)) 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)); + iv0->base, build_one_cst (type1)); bounds_add (bnds, double_int_one, type1); @@ -1282,7 +1282,7 @@ number_of_iterations_cond (struct loop *loop, iv0->step = fold_binary_to_constant (MINUS_EXPR, type, iv0->step, iv1->step); iv0->no_overflow = false; - iv1->step = build_int_cst (type, 0); + iv1->step = build_zero_cst (type); iv1->no_overflow = true; } @@ -1305,7 +1305,7 @@ number_of_iterations_cond (struct loop *loop, /* If the loop exits immediately, there is nothing to do. */ if (integer_zerop (fold_build2 (code, boolean_type_node, iv0->base, iv1->base))) { - niter->niter = build_int_cst (unsigned_type_for (type), 0); + niter->niter = build_zero_cst (unsigned_type_for (type)); niter->max = double_int_zero; return true; } @@ -1946,7 +1946,7 @@ find_loop_niter (struct loop *loop, edge *exit) { /* We exit in the first iteration through this exit. We won't find anything better. */ - niter = build_int_cst (unsigned_type_node, 0); + niter = build_zero_cst (unsigned_type_node); *exit = ex; break; } @@ -3017,7 +3017,7 @@ estimate_numbers_of_iterations_loop (struct loop *loop, bool use_undefined_p) type = TREE_TYPE (niter); if (TREE_CODE (niter_desc.may_be_zero) != INTEGER_CST) niter = build3 (COND_EXPR, type, niter_desc.may_be_zero, - build_int_cst (type, 0), + build_zero_cst (type), niter); record_estimate (loop, niter, niter_desc.max, last_stmt (ex->src),