aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-chrec.c
diff options
context:
space:
mode:
authorBin Cheng <bin.cheng@arm.com>2016-07-21 10:52:13 +0000
committerBin Cheng <amker@gcc.gnu.org>2016-07-21 10:52:13 +0000
commitb24d94207914fb8695bd7307187a5a0bfcddc8c2 (patch)
tree5395d978a3d736c900e79a29efb655abdb1d10e6 /gcc/tree-chrec.c
parent106d07f8d20542c5a0acad3699843aa26b2ee84f (diff)
downloadgcc-b24d94207914fb8695bd7307187a5a0bfcddc8c2.zip
gcc-b24d94207914fb8695bd7307187a5a0bfcddc8c2.tar.gz
gcc-b24d94207914fb8695bd7307187a5a0bfcddc8c2.tar.bz2
tree-chrec.c (convert_affine_scev): New parameter.
* tree-chrec.c (convert_affine_scev): New parameter. Pass new arg. (chrec_convert_1, chrec_convert): Ditto. * tree-chrec.h (chrec_convert, convert_affine_scev): New parameter. * tree-scalar-evolution.c (interpret_rhs_expr): Pass new arg. * tree-vrp.c (adjust_range_with_scev): Ditto. * tree-ssa-loop-niter.c (idx_infer_loop_bounds): Ditto. (scev_var_range_cant_overflow): New function. (scev_probably_wraps_p): New parameter. Call above function. * tree-ssa-loop-niter.h (scev_probably_wraps_p): New parameter. gcc/testsuite * gcc.dg/tree-ssa/scev-15.c: New. From-SVN: r238586
Diffstat (limited to 'gcc/tree-chrec.c')
-rw-r--r--gcc/tree-chrec.c40
1 files changed, 23 insertions, 17 deletions
diff --git a/gcc/tree-chrec.c b/gcc/tree-chrec.c
index ee789a2..707a3aa 100644
--- a/gcc/tree-chrec.c
+++ b/gcc/tree-chrec.c
@@ -1162,16 +1162,17 @@ nb_vars_in_chrec (tree chrec)
/* Converts BASE and STEP of affine scev to TYPE. LOOP is the loop whose iv
the scev corresponds to. AT_STMT is the statement at that the scev is
- evaluated. USE_OVERFLOW_SEMANTICS is true if this function should assume that
- the rules for overflow of the given language apply (e.g., that signed
- arithmetics in C does not overflow) -- i.e., to use them to avoid unnecessary
- tests, but also to enforce that the result follows them. Returns true if the
- conversion succeeded, false otherwise. */
+ evaluated. USE_OVERFLOW_SEMANTICS is true if this function should assume
+ that the rules for overflow of the given language apply (e.g., that signed
+ arithmetics in C does not overflow) -- i.e., to use them to avoid
+ unnecessary tests, but also to enforce that the result follows them.
+ FROM is the source variable converted if it's not NULL. Returns true if
+ the conversion succeeded, false otherwise. */
bool
convert_affine_scev (struct loop *loop, tree type,
tree *base, tree *step, gimple *at_stmt,
- bool use_overflow_semantics)
+ bool use_overflow_semantics, tree from)
{
tree ct = TREE_TYPE (*step);
bool enforce_overflow_semantics;
@@ -1230,7 +1231,7 @@ convert_affine_scev (struct loop *loop, tree type,
must_check_rslt_overflow = false;
if (must_check_src_overflow
- && scev_probably_wraps_p (*base, *step, at_stmt, loop,
+ && scev_probably_wraps_p (from, *base, *step, at_stmt, loop,
use_overflow_semantics))
return false;
@@ -1258,7 +1259,8 @@ convert_affine_scev (struct loop *loop, tree type,
if (must_check_rslt_overflow
/* Note that in this case we cannot use the fact that signed variables
do not overflow, as this is what we are verifying for the new iv. */
- && scev_probably_wraps_p (new_base, new_step, at_stmt, loop, false))
+ && scev_probably_wraps_p (NULL_TREE, new_base, new_step,
+ at_stmt, loop, false))
return false;
*base = new_base;
@@ -1288,12 +1290,14 @@ chrec_convert_rhs (tree type, tree chrec, gimple *at_stmt)
USE_OVERFLOW_SEMANTICS is true if this function should assume that
the rules for overflow of the given language apply (e.g., that signed
- arithmetics in C does not overflow) -- i.e., to use them to avoid unnecessary
- tests, but also to enforce that the result follows them. */
+ arithmetics in C does not overflow) -- i.e., to use them to avoid
+ unnecessary tests, but also to enforce that the result follows them.
+
+ FROM is the source variable converted if it's not NULL. */
static tree
chrec_convert_1 (tree type, tree chrec, gimple *at_stmt,
- bool use_overflow_semantics)
+ bool use_overflow_semantics, tree from)
{
tree ct, res;
tree base, step;
@@ -1314,7 +1318,7 @@ chrec_convert_1 (tree type, tree chrec, gimple *at_stmt,
step = CHREC_RIGHT (chrec);
if (convert_affine_scev (loop, type, &base, &step, at_stmt,
- use_overflow_semantics))
+ use_overflow_semantics, from))
return build_polynomial_chrec (loop->num, base, step);
/* If we cannot propagate the cast inside the chrec, just keep the cast. */
@@ -1347,7 +1351,7 @@ keep_cast:
CHREC_LEFT (chrec)),
fold_convert (utype,
CHREC_RIGHT (chrec)));
- res = chrec_convert_1 (type, res, at_stmt, use_overflow_semantics);
+ res = chrec_convert_1 (type, res, at_stmt, use_overflow_semantics, from);
}
else
res = fold_convert (type, chrec);
@@ -1395,14 +1399,16 @@ keep_cast:
USE_OVERFLOW_SEMANTICS is true if this function should assume that
the rules for overflow of the given language apply (e.g., that signed
- arithmetics in C does not overflow) -- i.e., to use them to avoid unnecessary
- tests, but also to enforce that the result follows them. */
+ arithmetics in C does not overflow) -- i.e., to use them to avoid
+ unnecessary tests, but also to enforce that the result follows them.
+
+ FROM is the source variable converted if it's not NULL. */
tree
chrec_convert (tree type, tree chrec, gimple *at_stmt,
- bool use_overflow_semantics)
+ bool use_overflow_semantics, tree from)
{
- return chrec_convert_1 (type, chrec, at_stmt, use_overflow_semantics);
+ return chrec_convert_1 (type, chrec, at_stmt, use_overflow_semantics, from);
}
/* Convert CHREC to TYPE, without regard to signed overflows. Returns the new