aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Pop <sebastian.pop@amd.com>2010-04-06 21:03:37 +0000
committerSebastian Pop <spop@gcc.gnu.org>2010-04-06 21:03:37 +0000
commitb8132a7dfb20b9dbc52a5ef171deea6d3fb6eab1 (patch)
tree7fb4a995bc0963ed0f1d9b9e0400671db72593ab
parentdbe0d6521664869b3b0d1f9e24f0a4e657964fe8 (diff)
downloadgcc-b8132a7dfb20b9dbc52a5ef171deea6d3fb6eab1.zip
gcc-b8132a7dfb20b9dbc52a5ef171deea6d3fb6eab1.tar.gz
gcc-b8132a7dfb20b9dbc52a5ef171deea6d3fb6eab1.tar.bz2
Fix 473.astar miscompile.
2010-04-05 Sebastian Pop <sebastian.pop@amd.com> PR middle-end/43519 * graphite-clast-to-gimple.c (max_signed_precision_type): Use lang_hooks.types.type_for_size instead of build_nonstandard_integer_type. When converting an unsigned type to signed, double its precision. (gcc_type_for_interval): Use lang_hooks.types.type_for_size. (gcc_type_for_iv_of_clast_loop): Call max_signed_precision_type. (graphite_create_new_loop_guard): When ub + 1 wraps around, use lb <= ub. From-SVN: r158028
-rw-r--r--gcc/ChangeLog.graphite19
-rw-r--r--gcc/graphite-clast-to-gimple.c36
2 files changed, 42 insertions, 13 deletions
diff --git a/gcc/ChangeLog.graphite b/gcc/ChangeLog.graphite
index 89e1a0a..bdeaf83 100644
--- a/gcc/ChangeLog.graphite
+++ b/gcc/ChangeLog.graphite
@@ -1,4 +1,21 @@
-2010-04-04 Sebastian Pop <sebastian.pop@amd.com>
+2010-04-05 Sebastian Pop <sebastian.pop@amd.com>
+
+ PR middle-end/43519
+ * graphite-clast-to-gimple.c (max_signed_precision_type): Use
+ lang_hooks.types.type_for_size instead of build_nonstandard_integer_type.
+ When converting an unsigned type to signed, double its precision.
+ (gcc_type_for_interval): Use lang_hooks.types.type_for_size.
+ (gcc_type_for_iv_of_clast_loop): Call max_signed_precision_type.
+ (graphite_create_new_loop_guard): When ub + 1 wraps around, use lb <= ub.
+
+2010-04-05 Sebastian Pop <sebastian.pop@amd.com>
+
+ PR middle-end/43519
+ * graphite-clast-to-gimple.c (max_signed_precision_type): Use
+ build_nonstandard_integer_type.
+ (gcc_type_for_interval): Same.
+
+2010-04-05 Sebastian Pop <sebastian.pop@amd.com>
PR middle-end/43519
* graphite-clast-to-gimple.c (graphite_create_new_loop_guard): Use
diff --git a/gcc/graphite-clast-to-gimple.c b/gcc/graphite-clast-to-gimple.c
index 106ff7c..01d141f 100644
--- a/gcc/graphite-clast-to-gimple.c
+++ b/gcc/graphite-clast-to-gimple.c
@@ -231,8 +231,15 @@ max_signed_precision_type (tree type1, tree type2)
{
int p1 = TYPE_PRECISION (type1);
int p2 = TYPE_PRECISION (type2);
- int precision = p1 > p2 ? p1 : p2;
- tree type = lang_hooks.types.type_for_size (precision, false);
+ int precision;
+ tree type;
+
+ if (p1 > p2)
+ precision = TYPE_UNSIGNED (type1) ? p1 * 2 : p1;
+ else
+ precision = TYPE_UNSIGNED (type2) ? p2 * 2 : p2;
+
+ type = lang_hooks.types.type_for_size (precision, false);
if (!type)
{
@@ -247,7 +254,6 @@ max_signed_precision_type (tree type1, tree type2)
static tree
max_precision_type (tree type1, tree type2)
{
-
if (POINTER_TYPE_P (type1))
return type1;
@@ -790,9 +796,9 @@ gcc_type_for_iv_of_clast_loop (struct clast_for *stmt_for, int level,
CloogStatement *cs = body->statement;
poly_bb_p pbb = (poly_bb_p) cloog_statement_usr (cs);
- return max_precision_type (lb_type, max_precision_type
- (ub_type, compute_type_for_level (pbb,
- level - 1)));
+ return max_signed_precision_type (lb_type, max_precision_type
+ (ub_type, compute_type_for_level
+ (pbb, level - 1)));
}
/* Creates a new LOOP corresponding to Cloog's STMT. Inserts an
@@ -1022,22 +1028,28 @@ graphite_create_new_loop_guard (sese region, edge entry_edge,
newivs_index, params_index);
tree ub = clast_to_gcc_expression (type, stmt->UB, region, newivs,
newivs_index, params_index);
+ tree ub_one;
- /* XXX: Adding +1 and using LT_EXPR helps with loop latches that have a
+ /* Adding +1 and using LT_EXPR helps with loop latches that have a
loop iteration count of "PARAMETER - 1". For PARAMETER == 0 this becomes
2^{32|64}, and the condition lb <= ub is true, even if we do not want this.
- However lb < ub + 1 is false, as expected.
- There might be a problem with cases where ub is 2^32. */
+ However lb < ub + 1 is false, as expected. */
tree one;
Value gmp_one;
+
value_init (gmp_one);
value_set_si (gmp_one, 1);
one = gmp_cst_to_tree (type, gmp_one);
value_clear (gmp_one);
- ub = fold_build2 (POINTER_TYPE_P (type) ? POINTER_PLUS_EXPR : PLUS_EXPR,
- type, ub, one);
- cond_expr = fold_build2 (LT_EXPR, boolean_type_node, lb, ub);
+ ub_one = fold_build2 (POINTER_TYPE_P (type) ? POINTER_PLUS_EXPR : PLUS_EXPR,
+ type, ub, one);
+
+ /* When ub + 1 wraps around, use lb <= ub. */
+ if (integer_zerop (ub_one))
+ cond_expr = fold_build2 (LE_EXPR, boolean_type_node, lb, ub);
+ else
+ cond_expr = fold_build2 (LT_EXPR, boolean_type_node, lb, ub_one);
exit_edge = create_empty_if_region_on_edge (entry_edge, cond_expr);