diff options
Diffstat (limited to 'gcc/tree-scalar-evolution.c')
-rw-r--r-- | gcc/tree-scalar-evolution.c | 45 |
1 files changed, 27 insertions, 18 deletions
diff --git a/gcc/tree-scalar-evolution.c b/gcc/tree-scalar-evolution.c index 09fd5e9..f1a2efa 100644 --- a/gcc/tree-scalar-evolution.c +++ b/gcc/tree-scalar-evolution.c @@ -476,12 +476,12 @@ compute_overall_effect_of_inner_loop (struct loop *loop, tree evolution_fn) else { tree res; + tree type = chrec_type (nb_iter); /* Number of iterations is off by one (the ssa name we analyze must be defined before the exit). */ - nb_iter = chrec_fold_minus (chrec_type (nb_iter), - nb_iter, - build_int_cst_type (chrec_type (nb_iter), 1)); + nb_iter = chrec_fold_minus (type, nb_iter, + build_int_cst_type (type, 1)); /* evolution_fn is the evolution function in LOOP. Get its value in the nb_iter-th iteration. */ @@ -510,10 +510,8 @@ compute_overall_effect_of_inner_loop (struct loop *loop, tree evolution_fn) bool chrec_is_positive (tree chrec, bool *value) { - bool value0, value1; - bool value2; - tree end_value; - tree nb_iter; + bool value0, value1, value2; + tree type, end_value, nb_iter; switch (TREE_CODE (chrec)) { @@ -542,17 +540,14 @@ chrec_is_positive (tree chrec, bool *value) if (chrec_contains_undetermined (nb_iter)) return false; - nb_iter = chrec_fold_minus - (chrec_type (nb_iter), nb_iter, - build_int_cst (chrec_type (nb_iter), 1)); + type = chrec_type (nb_iter); + nb_iter = chrec_fold_minus (type, nb_iter, build_int_cst (type, 1)); #if 0 /* TODO -- If the test is after the exit, we may decrease the number of iterations by one. */ if (after_exit) - nb_iter = chrec_fold_minus - (chrec_type (nb_iter), nb_iter, - build_int_cst (chrec_type (nb_iter), 1)); + nb_iter = chrec_fold_minus (type, nb_iter, build_int_cst (type, 1)); #endif end_value = chrec_apply (CHREC_VARIABLE (chrec), chrec, nb_iter); @@ -900,8 +895,9 @@ static inline tree set_nb_iterations_in_loop (struct loop *loop, tree res) { - res = chrec_fold_plus (chrec_type (res), res, - build_int_cst_type (chrec_type (res), 1)); + tree type = chrec_type (res); + + res = chrec_fold_plus (type, res, build_int_cst_type (type, 1)); /* FIXME HWI: However we want to store one iteration less than the count of the loop in order to be compatible with the other @@ -1958,6 +1954,7 @@ instantiate_parameters_1 (struct loop *loop, tree chrec, int flags, htab_t cache tree res, op0, op1, op2; basic_block def_bb; struct loop *def_loop; + tree type = chrec_type (chrec); /* Give up if the expression is larger than the MAX that we allow. */ if (size_expr++ > PARAM_VALUE (PARAM_SCEV_MAX_EXPR_SIZE)) @@ -2070,7 +2067,11 @@ instantiate_parameters_1 (struct loop *loop, tree chrec, int flags, htab_t cache if (TREE_OPERAND (chrec, 0) != op0 || TREE_OPERAND (chrec, 1) != op1) - chrec = chrec_fold_plus (TREE_TYPE (chrec), op0, op1); + { + op0 = chrec_convert (type, op0, NULL_TREE); + op1 = chrec_convert (type, op1, NULL_TREE); + chrec = chrec_fold_plus (type, op0, op1); + } return chrec; case MINUS_EXPR: @@ -2086,7 +2087,11 @@ instantiate_parameters_1 (struct loop *loop, tree chrec, int flags, htab_t cache if (TREE_OPERAND (chrec, 0) != op0 || TREE_OPERAND (chrec, 1) != op1) - chrec = chrec_fold_minus (TREE_TYPE (chrec), op0, op1); + { + op0 = chrec_convert (type, op0, NULL_TREE); + op1 = chrec_convert (type, op1, NULL_TREE); + chrec = chrec_fold_minus (type, op0, op1); + } return chrec; case MULT_EXPR: @@ -2102,7 +2107,11 @@ instantiate_parameters_1 (struct loop *loop, tree chrec, int flags, htab_t cache if (TREE_OPERAND (chrec, 0) != op0 || TREE_OPERAND (chrec, 1) != op1) - chrec = chrec_fold_multiply (TREE_TYPE (chrec), op0, op1); + { + op0 = chrec_convert (type, op0, NULL_TREE); + op1 = chrec_convert (type, op1, NULL_TREE); + chrec = chrec_fold_multiply (type, op0, op1); + } return chrec; case NOP_EXPR: |