Commit fa8ce189 by Richard Biener Committed by Richard Biener

graphite-sese-to-poly.c (extract_affine): Avoid unneded wrapping.

2018-06-07  Richard Biener  <rguenther@suse.de>

	* graphite-sese-to-poly.c (extract_affine): Avoid unneded
	wrapping.  Properly wrap the result of a BIT_NOT_EXPR.
	Properly wrap signed arithmetic if overflow wraps.

From-SVN: r261267
parent c962b2c3
2018-06-07 Richard Biener <rguenther@suse.de>
* graphite-sese-to-poly.c (extract_affine): Avoid unneded
wrapping. Properly wrap the result of a BIT_NOT_EXPR.
Properly wrap signed arithmetic if overflow wraps.
2018-06-07 Jakub Jelinek <jakub@redhat.com> 2018-06-07 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/69615 PR tree-optimization/69615
......
...@@ -272,7 +272,8 @@ extract_affine (scop_p s, tree e, __isl_take isl_space *space) ...@@ -272,7 +272,8 @@ extract_affine (scop_p s, tree e, __isl_take isl_space *space)
lhs = extract_affine (s, integer_minus_one_node, isl_space_copy (space)); lhs = extract_affine (s, integer_minus_one_node, isl_space_copy (space));
rhs = extract_affine (s, TREE_OPERAND (e, 0), space); rhs = extract_affine (s, TREE_OPERAND (e, 0), space);
res = isl_pw_aff_sub (lhs, rhs); res = isl_pw_aff_sub (lhs, rhs);
break; /* We need to always wrap the result of a bitwise operation. */
return wrap (res, TYPE_PRECISION (type) - (TYPE_UNSIGNED (type) ? 0 : 1));
case NEGATE_EXPR: case NEGATE_EXPR:
lhs = extract_affine (s, TREE_OPERAND (e, 0), isl_space_copy (space)); lhs = extract_affine (s, TREE_OPERAND (e, 0), isl_space_copy (space));
...@@ -285,8 +286,8 @@ extract_affine (scop_p s, tree e, __isl_take isl_space *space) ...@@ -285,8 +286,8 @@ extract_affine (scop_p s, tree e, __isl_take isl_space *space)
gcc_assert (! defined_in_sese_p (e, s->scop_info->region)); gcc_assert (! defined_in_sese_p (e, s->scop_info->region));
int dim = parameter_index_in_region (e, s->scop_info); int dim = parameter_index_in_region (e, s->scop_info);
gcc_assert (dim != -1); gcc_assert (dim != -1);
res = extract_affine_name (dim, space); /* No need to wrap a parameter. */
break; return extract_affine_name (dim, space);
} }
case INTEGER_CST: case INTEGER_CST:
...@@ -301,11 +302,15 @@ extract_affine (scop_p s, tree e, __isl_take isl_space *space) ...@@ -301,11 +302,15 @@ extract_affine (scop_p s, tree e, __isl_take isl_space *space)
/* Signed values, even if overflow is undefined, get modulo-reduced. /* Signed values, even if overflow is undefined, get modulo-reduced.
But only if not all values of the old type fit in the new. */ But only if not all values of the old type fit in the new. */
if (! TYPE_UNSIGNED (type) if (! TYPE_UNSIGNED (type)
&& ((TYPE_UNSIGNED (TREE_TYPE (TREE_OPERAND (e, 0))) && ((TYPE_UNSIGNED (itype)
&& TYPE_PRECISION (type) <= TYPE_PRECISION (itype)) && TYPE_PRECISION (type) <= TYPE_PRECISION (itype))
|| TYPE_PRECISION (type) < TYPE_PRECISION (itype))) || TYPE_PRECISION (type) < TYPE_PRECISION (itype)))
res = wrap (res, TYPE_PRECISION (type) - 1); res = wrap (res, TYPE_PRECISION (type) - 1);
break; else if (TYPE_UNSIGNED (type)
&& (!TYPE_UNSIGNED (itype)
|| TYPE_PRECISION (type) < TYPE_PRECISION (itype)))
res = wrap (res, TYPE_PRECISION (type));
return res;
} }
case NON_LVALUE_EXPR: case NON_LVALUE_EXPR:
...@@ -317,7 +322,8 @@ extract_affine (scop_p s, tree e, __isl_take isl_space *space) ...@@ -317,7 +322,8 @@ extract_affine (scop_p s, tree e, __isl_take isl_space *space)
break; break;
} }
if (TYPE_UNSIGNED (type)) /* For all wrapping arithmetic wrap the result. */
if (TYPE_OVERFLOW_WRAPS (type))
res = wrap (res, TYPE_PRECISION (type)); res = wrap (res, TYPE_PRECISION (type));
return res; return res;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment