diff options
author | Richard Guenther <rguenther@suse.de> | 2012-06-27 11:32:30 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2012-06-27 11:32:30 +0000 |
commit | 195b4c507f3c0552ac78530513e4da5d227215c6 (patch) | |
tree | d0a3413286a82915919c9aaf8c25c24327aaa711 /gcc/tree-chrec.c | |
parent | be7493cabbc288d598ac3ede0fc8395e780d1cfa (diff) | |
download | gcc-195b4c507f3c0552ac78530513e4da5d227215c6.tar.gz |
re PR middle-end/53676 (empty loop is not always removed now)
2012-06-27 Richard Guenther <rguenther@suse.de>
PR middle-end/53676
* tree-chrec.c (chrec_convert_1): Represent truncation to
a type with undefined overflow as truncation to an unsigned
type converted to the type with undefined overflow.
* tree-scalar-evolution.c (interpret_rhs_expr): For computing
the scalar evolution of a truncated widened operation avoid
looking at the non-existing evolution of the widened operation
result.
* gcc.dg/tree-ssa/scev-6.c: New testcase.
From-SVN: r189013
Diffstat (limited to 'gcc/tree-chrec.c')
-rw-r--r-- | gcc/tree-chrec.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/gcc/tree-chrec.c b/gcc/tree-chrec.c index 38dca4ab1dd..82c3771b8a5 100644 --- a/gcc/tree-chrec.c +++ b/gcc/tree-chrec.c @@ -1365,6 +1365,23 @@ keep_cast: res = fold_build2 (TREE_CODE (chrec), type, fold_convert (type, TREE_OPERAND (chrec, 0)), fold_convert (type, TREE_OPERAND (chrec, 1))); + /* Similar perform the trick that (signed char)((int)x + 2) can be + narrowed to (signed char)((unsigned char)x + 2). */ + else if (use_overflow_semantics + && TREE_CODE (chrec) == POLYNOMIAL_CHREC + && TREE_CODE (ct) == INTEGER_TYPE + && TREE_CODE (type) == INTEGER_TYPE + && TYPE_OVERFLOW_UNDEFINED (type) + && TYPE_PRECISION (type) < TYPE_PRECISION (ct)) + { + tree utype = unsigned_type_for (type); + res = build_polynomial_chrec (CHREC_VARIABLE (chrec), + fold_convert (utype, + CHREC_LEFT (chrec)), + fold_convert (utype, + CHREC_RIGHT (chrec))); + res = chrec_convert_1 (type, res, at_stmt, use_overflow_semantics); + } else res = fold_convert (type, chrec); |