aboutsummaryrefslogtreecommitdiff
path: root/gcc/graphite-sese-to-poly.c
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2017-09-20 07:34:55 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2017-09-20 07:34:55 +0000
commitf6b5c26b8a6c827ec20445daad76a6cee0435e0e (patch)
tree6b578530d2ea16b4385843b92344b9473b2fabb9 /gcc/graphite-sese-to-poly.c
parent73fe2f3229f1e1be902ffd09c42b444e5af9e7f5 (diff)
downloadgcc-f6b5c26b8a6c827ec20445daad76a6cee0435e0e.zip
gcc-f6b5c26b8a6c827ec20445daad76a6cee0435e0e.tar.gz
gcc-f6b5c26b8a6c827ec20445daad76a6cee0435e0e.tar.bz2
graphite-sese-to-poly.c (extract_affine): Properly handle POINTER_PLUS_EXPR, BIT_NOT_EXPR and conversion to signed.
2017-09-20 Richard Biener <rguenther@suse.de> * graphite-sese-to-poly.c (extract_affine): Properly handle POINTER_PLUS_EXPR, BIT_NOT_EXPR and conversion to signed. From-SVN: r253001
Diffstat (limited to 'gcc/graphite-sese-to-poly.c')
-rw-r--r--gcc/graphite-sese-to-poly.c31
1 files changed, 28 insertions, 3 deletions
diff --git a/gcc/graphite-sese-to-poly.c b/gcc/graphite-sese-to-poly.c
index 6e64f13..5d6ba67 100644
--- a/gcc/graphite-sese-to-poly.c
+++ b/gcc/graphite-sese-to-poly.c
@@ -237,6 +237,7 @@ extract_affine (scop_p s, tree e, __isl_take isl_space *space)
return NULL;
}
+ tree type = TREE_TYPE (e);
switch (TREE_CODE (e))
{
case POLYNOMIAL_CHREC:
@@ -247,8 +248,22 @@ extract_affine (scop_p s, tree e, __isl_take isl_space *space)
res = extract_affine_mul (s, e, space);
break;
- case PLUS_EXPR:
case POINTER_PLUS_EXPR:
+ {
+ lhs = extract_affine (s, TREE_OPERAND (e, 0), isl_space_copy (space));
+ /* The RHS of a pointer-plus expression is to be interpreted
+ as signed value. Try to look through a sign-changing conversion
+ first. */
+ tree tem = TREE_OPERAND (e, 1);
+ STRIP_NOPS (tem);
+ rhs = extract_affine (s, tem, space);
+ if (TYPE_UNSIGNED (TREE_TYPE (tem)))
+ rhs = wrap (rhs, TYPE_PRECISION (type) - 1);
+ res = isl_pw_aff_add (lhs, rhs);
+ break;
+ }
+
+ case PLUS_EXPR:
lhs = extract_affine (s, TREE_OPERAND (e, 0), isl_space_copy (space));
rhs = extract_affine (s, TREE_OPERAND (e, 1), space);
res = isl_pw_aff_add (lhs, rhs);
@@ -260,8 +275,13 @@ extract_affine (scop_p s, tree e, __isl_take isl_space *space)
res = isl_pw_aff_sub (lhs, rhs);
break;
- case NEGATE_EXPR:
case BIT_NOT_EXPR:
+ lhs = extract_affine (s, integer_minus_one_node, isl_space_copy (space));
+ rhs = extract_affine (s, TREE_OPERAND (e, 0), space);
+ res = isl_pw_aff_sub (lhs, rhs);
+ break;
+
+ case NEGATE_EXPR:
lhs = extract_affine (s, TREE_OPERAND (e, 0), isl_space_copy (space));
rhs = extract_affine (s, integer_minus_one_node, space);
res = isl_pw_aff_mul (lhs, rhs);
@@ -279,6 +299,12 @@ 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;
+
case NON_LVALUE_EXPR:
res = extract_affine (s, TREE_OPERAND (e, 0), space);
break;
@@ -288,7 +314,6 @@ extract_affine (scop_p s, tree e, __isl_take isl_space *space)
break;
}
- tree type = TREE_TYPE (e);
if (TYPE_UNSIGNED (type))
res = wrap (res, TYPE_PRECISION (type));