aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZdenek Dvorak <dvorakz@suse.cz>2006-07-17 19:09:39 +0200
committerZdenek Dvorak <rakdver@gcc.gnu.org>2006-07-17 17:09:39 +0000
commit64a7ab5f164ca0dc6f665f28924c013bddd3c1f9 (patch)
tree2032ba2e06db5aa8274553edc0cc5c99f9c06659
parent9fbe658520a6ee5527f85d0f1e6ff900bf32f988 (diff)
downloadgcc-64a7ab5f164ca0dc6f665f28924c013bddd3c1f9.zip
gcc-64a7ab5f164ca0dc6f665f28924c013bddd3c1f9.tar.gz
gcc-64a7ab5f164ca0dc6f665f28924c013bddd3c1f9.tar.bz2
tree-chrec.c (avoid_arithmetics_in_type_p): New.
* tree-chrec.c (avoid_arithmetics_in_type_p): New. (convert_affine_scev, chrec_convert_aggressive): Use avoid_arithmetics_in_type_p. Do not check for the subtypes separately. From-SVN: r115528
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/tree-chrec.c45
2 files changed, 31 insertions, 21 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 7a7b79f..c9a46c0 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,10 @@
+2006-07-17 Zdenek Dvorak <dvorakz@suse.cz>
+
+ * tree-chrec.c (avoid_arithmetics_in_type_p): New.
+ (convert_affine_scev, chrec_convert_aggressive): Use
+ avoid_arithmetics_in_type_p. Do not check for the subtypes
+ separately.
+
2006-07-17 Richard Sandiford <richard@codesourcery.com>
PR middle-end/28403
diff --git a/gcc/tree-chrec.c b/gcc/tree-chrec.c
index 8038b12..f9b804e 100644
--- a/gcc/tree-chrec.c
+++ b/gcc/tree-chrec.c
@@ -1096,6 +1096,21 @@ nb_vars_in_chrec (tree chrec)
}
}
+/* Returns true if TYPE is a type in that we cannot directly perform
+ arithmetics, even though it is a scalar type. */
+
+static bool
+avoid_arithmetics_in_type_p (tree type)
+{
+ /* Ada frontend uses subtypes -- an arithmetic cannot be directly performed
+ in the subtype, but a base type must be used, and the result then can
+ be casted to the subtype. */
+ if (TREE_CODE (type) == INTEGER_TYPE && TREE_TYPE (type) != NULL_TREE)
+ return true;
+
+ return false;
+}
+
static tree chrec_convert_1 (tree, tree, tree, bool);
/* Converts BASE and STEP of affine scev to TYPE. LOOP is the loop whose iv
@@ -1116,6 +1131,10 @@ convert_affine_scev (struct loop *loop, tree type,
bool must_check_src_overflow, must_check_rslt_overflow;
tree new_base, new_step;
+ /* If we cannot perform arithmetic in TYPE, avoid creating an scev. */
+ if (avoid_arithmetics_in_type_p (type))
+ return false;
+
/* In general,
(TYPE) (BASE + STEP * i) = (TYPE) BASE + (TYPE -- sign extend) STEP * i,
but we must check some assumptions.
@@ -1305,6 +1324,10 @@ chrec_convert_aggressive (tree type, tree chrec)
if (TYPE_PRECISION (type) > TYPE_PRECISION (inner_type))
return NULL_TREE;
+ /* If we cannot perform arithmetic in TYPE, avoid creating an scev. */
+ if (avoid_arithmetics_in_type_p (type))
+ return false;
+
left = CHREC_LEFT (chrec);
right = CHREC_RIGHT (chrec);
lc = chrec_convert_aggressive (type, left);
@@ -1313,27 +1336,7 @@ chrec_convert_aggressive (tree type, tree chrec)
rc = chrec_convert_aggressive (type, right);
if (!rc)
rc = chrec_convert (type, right, NULL_TREE);
-
- /* Ada creates sub-types where TYPE_MIN_VALUE/TYPE_MAX_VALUE do not
- cover the entire range of values allowed by TYPE_PRECISION.
-
- We do not want to optimize away conversions to such types. Long
- term I'd rather see the Ada front-end fixed. */
- if (INTEGRAL_TYPE_P (type))
- {
- tree t;
-
- t = upper_bound_in_type (type, inner_type);
- if (! TYPE_MAX_VALUE (type)
- || ! operand_equal_p (TYPE_MAX_VALUE (type), t, 0))
- return NULL_TREE;
-
- t = lower_bound_in_type (type, inner_type);
- if (! TYPE_MIN_VALUE (type)
- || ! operand_equal_p (TYPE_MIN_VALUE (type), t, 0))
- return NULL_TREE;
- }
-
+
return build_polynomial_chrec (CHREC_VARIABLE (chrec), lc, rc);
}