From 57cfa172280fd4a79a1d4120b69054457100af94 Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Fri, 6 Oct 2017 07:03:51 +0000 Subject: [PATCH] graphite-sese-to-poly.c (extract_affine): For casts increasing precision do not perform modulo reduction. 2017-10-06 Richard Biener * graphite-sese-to-poly.c (extract_affine): For casts increasing precision do not perform modulo reduction. From-SVN: r253474 --- gcc/ChangeLog | 5 +++++ gcc/graphite-sese-to-poly.c | 17 ++++++++++++----- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 06aaa06f75d..54ba096a161 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2017-10-06 Richard Biener + + * graphite-sese-to-poly.c (extract_affine): For casts increasing + precision do not perform modulo reduction. + 2017-10-06 Richard Biener PR tree-optimization/82436 diff --git a/gcc/graphite-sese-to-poly.c b/gcc/graphite-sese-to-poly.c index 8611e86cc60..6cd5bc7c9d9 100644 --- a/gcc/graphite-sese-to-poly.c +++ b/gcc/graphite-sese-to-poly.c @@ -299,11 +299,18 @@ extract_affine (scop_p s, tree e, __isl_take isl_space *space) return res; CASE_CONVERT: - res = extract_affine (s, TREE_OPERAND (e, 0), space); - /* signed values, even if overflow is undefined, get modulo-reduced. */ - if (! TYPE_UNSIGNED (type)) - res = wrap (res, TYPE_PRECISION (type) - 1); - break; + { + tree itype = TREE_TYPE (TREE_OPERAND (e, 0)); + res = extract_affine (s, TREE_OPERAND (e, 0), space); + /* Signed values, even if overflow is undefined, get modulo-reduced. + But only if not all values of the old type fit in the new. */ + if (! TYPE_UNSIGNED (type) + && ((TYPE_UNSIGNED (TREE_TYPE (TREE_OPERAND (e, 0))) + && TYPE_PRECISION (type) <= TYPE_PRECISION (itype)) + || TYPE_PRECISION (type) < TYPE_PRECISION (itype))) + res = wrap (res, TYPE_PRECISION (type) - 1); + break; + } case NON_LVALUE_EXPR: res = extract_affine (s, TREE_OPERAND (e, 0), space); -- 2.30.2