From 27a10c3f3f166db2dfd1a604f753985f880e11c0 Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Fri, 6 Oct 2017 07:03:51 +0000 Subject: 2017-10-06 Richard Biener * graphite-sese-to-poly.c (extract_affine): For casts increasing precision do not perform modulo reduction. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@253474 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 5 +++++ gcc/graphite-sese-to-poly.c | 17 ++++++++++++----- 2 files changed, 17 insertions(+), 5 deletions(-) (limited to 'gcc') 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); -- cgit v1.2.3