From patchwork Tue Jun 15 16:18:28 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: Fix PR44391: use size_one_node for pointer types. Date: Tue, 15 Jun 2010 06:18:28 -0000 From: Sebastian Pop X-Patchwork-Id: 55761 Message-Id: To: GCC Patches , gcc-graphite Hi, The attached patch fixes PR44391 by using size_one_node instead of the conversion of the GMP constant 1 to a tree of the given type, that could be a pointer to "unsigned char *" as in the attached testcase. The patch cleans up all this code avoiding GMP. I will commit this to trunk once it passes regstrap on amd64-linux. Sebastian >From e0ca0e9de1a14d0a4fed652796bdce10bc7f4538 Mon Sep 17 00:00:00 2001 From: Sebastian Pop Date: Tue, 15 Jun 2010 11:08:57 -0500 Subject: [PATCH] Fix PR44391: use size_one_node for pointer types. PR middle-end/44391 * graphite-clast-to-gimple.c (graphite_create_new_loop_guard): Use size_one_node for pointer types. Do not call gmp_cst_to_tree. * gcc.dg/graphite/pr44391.c: New. --- gcc/graphite-clast-to-gimple.c | 17 +++++------------ gcc/testsuite/gcc.dg/graphite/pr44391.c | 7 +++++++ 2 files changed, 12 insertions(+), 12 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/graphite/pr44391.c diff --git a/gcc/graphite-clast-to-gimple.c b/gcc/graphite-clast-to-gimple.c index 8116afe..b6b8d31 100644 --- a/gcc/graphite-clast-to-gimple.c +++ b/gcc/graphite-clast-to-gimple.c @@ -991,6 +991,7 @@ translate_clast_user (sese region, struct clast_user_stmt *stmt, edge next_e, /* Creates a new if region protecting the loop to be executed, if the execution count is zero (lb > ub). */ + static edge graphite_create_new_loop_guard (sese region, edge entry_edge, struct clast_for *stmt, @@ -1008,22 +1009,14 @@ 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; - + tree one = POINTER_TYPE_P (type) ? size_one_node + : fold_convert (type, integer_one_node); /* 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. */ - tree one; - mpz_t gmp_one; - - mpz_init (gmp_one); - mpz_set_si (gmp_one, 1); - one = gmp_cst_to_tree (type, gmp_one); - mpz_clear (gmp_one); - - ub_one = fold_build2 (POINTER_TYPE_P (type) ? POINTER_PLUS_EXPR : PLUS_EXPR, - type, ub, one); + tree 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)) diff --git a/gcc/testsuite/gcc.dg/graphite/pr44391.c b/gcc/testsuite/gcc.dg/graphite/pr44391.c new file mode 100644 index 0000000..91b3afa --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/pr44391.c @@ -0,0 +1,7 @@ +/* { dg-options "-Os -m32 -fgraphite-identity -ffast-math" } */ + +void byte_insert_op1 (unsigned char *loc, unsigned char *end, unsigned *pto) +{ + while (end != loc) + *pto = *--end; +} -- 1.7.0.4