diff options
author | spop <spop@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-03-08 17:49:36 +0000 |
---|---|---|
committer | spop <spop@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-03-08 17:49:36 +0000 |
commit | b43389bdff99f059d2f593c0b3b5b3332f8131f2 (patch) | |
tree | 6a1a47eb427ba78c11b008b0e38679bf05584a5c /gcc/graphite-clast-to-gimple.c | |
parent | 2d0a2aaadcca869d985e2152914b82771207f754 (diff) | |
download | gcc-b43389bdff99f059d2f593c0b3b5b3332f8131f2.tar.gz |
Fix type problems in loop ivs.
Fix pr42644.
Fix pr42130 (dealII).
2010-03-03 Tobias Grosser <grosser@fim.uni-passau.de>
* gcc/graphite-clast-to-gimple.c (clast_to_gcc_expression): Also
handle conversions from pointer to integers.
(gcc_type_for_cloog_iv): Choose the smalles signed integer as an
induction variable, to be able to work with code generated by
CLooG.
* gcc/graphite-sese-to-poly.c (scop_ivs_can_be_represented): New.
(build_poly_scop): Bail out if we cannot codegen a loop.
* gcc/testsuite/gcc.dg/graphite/id-18.c: New.
* gcc/testsuite/gcc.dg/graphite/run-id-pr42644.c: New.
* libgomp/testsuite/libgomp.graphite/force-parallel-1.c: Adjust.
* libgomp/testsuite/libgomp.graphite/force-parallel-2.c: Adjust.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@157286 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/graphite-clast-to-gimple.c')
-rw-r--r-- | gcc/graphite-clast-to-gimple.c | 67 |
1 files changed, 60 insertions, 7 deletions
diff --git a/gcc/graphite-clast-to-gimple.c b/gcc/graphite-clast-to-gimple.c index fd631a4847e..64ddbb8ed91 100644 --- a/gcc/graphite-clast-to-gimple.c +++ b/gcc/graphite-clast-to-gimple.c @@ -282,14 +282,24 @@ clast_to_gcc_expression (tree type, struct clast_expr *e, { tree name = clast_name_to_gcc (t->var, region, newivs, newivs_index, params_index); - return fold_convert (type, name); + + if (POINTER_TYPE_P (TREE_TYPE (name)) != POINTER_TYPE_P (type)) + name = fold_convert (sizetype, name); + + name = fold_convert (type, name); + return name; } else if (value_mone_p (t->val)) { tree name = clast_name_to_gcc (t->var, region, newivs, newivs_index, params_index); + + if (POINTER_TYPE_P (TREE_TYPE (name)) != POINTER_TYPE_P (type)) + name = fold_convert (sizetype, name); + name = fold_convert (type, name); + return fold_build1 (NEGATE_EXPR, type, name); } else @@ -297,7 +307,12 @@ clast_to_gcc_expression (tree type, struct clast_expr *e, tree name = clast_name_to_gcc (t->var, region, newivs, newivs_index, params_index); tree cst = gmp_cst_to_tree (type, t->val); + + if (POINTER_TYPE_P (TREE_TYPE (name)) != POINTER_TYPE_P (type)) + name = fold_convert (sizetype, name); + name = fold_convert (type, name); + if (!POINTER_TYPE_P (type)) return fold_build2 (MULT_EXPR, type, cst, name); @@ -532,9 +547,16 @@ clast_get_body_of_loop (struct clast_stmt *stmt) gcc_unreachable (); } -/* Given a CLOOG_IV, returns the type that it should have in GCC land. - If the information is not available, i.e. in the case one of the - transforms created the loop, just return integer_type_node. */ +/* Given a CLOOG_IV, return the type that CLOOG_IV should have in GCC + land. The selected type is big enough to include the original loop + iteration variable, but signed to work with the subtractions CLooG + may have introduced. If such a type is not available, we fail. + + TODO: Do not always return long_long, but the smallest possible + type, that still holds the original type. + + TODO: Get the types using CLooG instead. This enables further + optimizations, but needs CLooG support. */ static tree gcc_type_for_cloog_iv (const char *cloog_iv, gimple_bb_p gbb) @@ -546,9 +568,40 @@ gcc_type_for_cloog_iv (const char *cloog_iv, gimple_bb_p gbb) slot = htab_find_slot (GBB_CLOOG_IV_TYPES (gbb), &tmp, NO_INSERT); if (slot && *slot) - return ((ivtype_map_elt) *slot)->type; + { + tree type = ((ivtype_map_elt) *slot)->type; + int type_precision = TYPE_PRECISION (type); + + /* Find the smallest signed type possible. */ + if (!TYPE_UNSIGNED (type)) + { + if (type_precision <= TYPE_PRECISION (integer_type_node)) + return integer_type_node; + + if (type_precision <= TYPE_PRECISION (long_integer_type_node)) + return long_integer_type_node; + + if (type_precision <= TYPE_PRECISION (long_long_integer_type_node)) + return long_long_integer_type_node; + + gcc_unreachable (); + } + + if (type_precision < TYPE_PRECISION (integer_type_node)) + return integer_type_node; + + if (type_precision < TYPE_PRECISION (long_integer_type_node)) + return long_integer_type_node; + + if (type_precision < TYPE_PRECISION (long_long_integer_type_node)) + return long_long_integer_type_node; + + /* There is no signed type available, that is large enough to hold the + original value. */ + gcc_unreachable (); + } - return integer_type_node; + return long_long_integer_type_node; } /* Returns the induction variable for the loop that gets translated to @@ -1046,7 +1099,7 @@ compute_cloog_iv_types_1 (poly_bb_p pbb, struct clast_user_stmt *user_stmt) if (slot && !*slot) { tree oldiv = pbb_to_depth_to_oldiv (pbb, index); - tree type = oldiv ? TREE_TYPE (oldiv) : integer_type_node; + tree type = TREE_TYPE (oldiv); *slot = new_ivtype_map_elt (tmp.cloog_iv, type); } } |