summaryrefslogtreecommitdiff
path: root/gcc/graphite-clast-to-gimple.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/graphite-clast-to-gimple.c')
-rw-r--r--gcc/graphite-clast-to-gimple.c63
1 files changed, 13 insertions, 50 deletions
diff --git a/gcc/graphite-clast-to-gimple.c b/gcc/graphite-clast-to-gimple.c
index 3240c37f8cf..b6b8d3134b1 100644
--- a/gcc/graphite-clast-to-gimple.c
+++ b/gcc/graphite-clast-to-gimple.c
@@ -469,11 +469,10 @@ precision_for_interval (mpz_t low, mpz_t up)
return precision;
}
-/* Return a type that could represent the integer value VAL, or
- otherwise return NULL_TREE. */
+/* Return a type that could represent the integer value VAL. */
static tree
-gcc_type_for_interval (mpz_t low, mpz_t up, tree old_type)
+gcc_type_for_interval (mpz_t low, mpz_t up)
{
bool unsigned_p = true;
int precision, prec_up, prec_int;
@@ -482,14 +481,12 @@ gcc_type_for_interval (mpz_t low, mpz_t up, tree old_type)
gcc_assert (value_le (low, up));
- /* Preserve the signedness of the old IV. */
- if ((old_type && !TYPE_UNSIGNED (old_type))
- || value_neg_p (low))
+ if (value_neg_p (low))
unsigned_p = false;
prec_up = precision_for_value (up);
prec_int = precision_for_interval (low, up);
- precision = prec_up > prec_int ? prec_up : prec_int;
+ precision = MAX (prec_up, prec_int);
if (precision > BITS_PER_WORD)
{
@@ -516,7 +513,7 @@ gcc_type_for_interval (mpz_t low, mpz_t up, tree old_type)
static tree
gcc_type_for_value (mpz_t val)
{
- return gcc_type_for_interval (val, val, NULL_TREE);
+ return gcc_type_for_interval (val, val);
}
/* Return the type for the clast_term T used in STMT. */
@@ -726,11 +723,10 @@ compute_bounds_for_level (poly_bb_p pbb, int level, mpz_t low, mpz_t up)
}
/* Compute the type for the induction variable at LEVEL for the
- statement PBB, based on the transformed schedule of PBB. OLD_TYPE
- is the type of the old induction variable for that loop. */
+ statement PBB, based on the transformed schedule of PBB. */
static tree
-compute_type_for_level_1 (poly_bb_p pbb, int level, tree old_type)
+compute_type_for_level (poly_bb_p pbb, int level)
{
mpz_t low, up;
tree type;
@@ -739,39 +735,13 @@ compute_type_for_level_1 (poly_bb_p pbb, int level, tree old_type)
value_init (up);
compute_bounds_for_level (pbb, level, low, up);
- type = gcc_type_for_interval (low, up, old_type);
+ type = gcc_type_for_interval (low, up);
value_clear (low);
value_clear (up);
return type;
}
-/* Compute the type for the induction variable at LEVEL for the
- statement PBB, based on the transformed schedule of PBB. */
-
-static tree
-compute_type_for_level (poly_bb_p pbb, int level)
-{
- tree oldiv = pbb_to_depth_to_oldiv (pbb, level);
- tree type = TREE_TYPE (oldiv);
-
- if (type && POINTER_TYPE_P (type))
- {
-#ifdef ENABLE_CHECKING
- tree ctype = compute_type_for_level_1 (pbb, level, type);
-
- /* In the case of a pointer type, check that after the loop
- transform, the lower and the upper bounds of the type fit the
- oldiv pointer type. */
- gcc_assert (TYPE_PRECISION (type) >= TYPE_PRECISION (ctype)
- && integer_zerop (lower_bound_in_type (ctype, ctype)));
-#endif
- return type;
- }
-
- return compute_type_for_level_1 (pbb, level, type);
-}
-
/* Walks a CLAST and returns the first statement in the body of a
loop. */
@@ -1021,6 +991,7 @@ translate_clast_user (sese region, struct clast_user_stmt *stmt, edge next_e,
/* Creates a new if region protecting the loop to be executed, if the execution
count is zero (lb > ub). */
+
static edge
graphite_create_new_loop_guard (sese region, edge entry_edge,
struct clast_for *stmt,
@@ -1038,22 +1009,14 @@ graphite_create_new_loop_guard (sese region, edge entry_edge,
newivs_index, params_index);
tree ub = clast_to_gcc_expression (type, stmt->UB, region, newivs,
newivs_index, params_index);
- tree ub_one;
-
+ tree one = POINTER_TYPE_P (type) ? size_one_node
+ : fold_convert (type, integer_one_node);
/* Adding +1 and using LT_EXPR helps with loop latches that have a
loop iteration count of "PARAMETER - 1". For PARAMETER == 0 this becomes
2^{32|64}, and the condition lb <= ub is true, even if we do not want this.
However lb < ub + 1 is false, as expected. */
- tree one;
- mpz_t gmp_one;
-
- mpz_init (gmp_one);
- mpz_set_si (gmp_one, 1);
- one = gmp_cst_to_tree (type, gmp_one);
- mpz_clear (gmp_one);
-
- ub_one = fold_build2 (POINTER_TYPE_P (type) ? POINTER_PLUS_EXPR : PLUS_EXPR,
- type, ub, one);
+ tree ub_one = fold_build2 (POINTER_TYPE_P (type) ? POINTER_PLUS_EXPR
+ : PLUS_EXPR, type, ub, one);
/* When ub + 1 wraps around, use lb <= ub. */
if (integer_zerop (ub_one))