From 12deddcb4439ab226cfd3ebdaf64d2ef0b277c0c Mon Sep 17 00:00:00 2001 From: Ramakrishna Upadrasta Date: Fri, 22 Jan 2010 17:41:37 +0100 Subject: [PATCH] Fix DealII type problems. 2010-01-22 Ramakrishna Upadrasta PR middle-end/42644 PR middle-end/42130 * graphite-clast-to-gimple.c (gcc_type_for_cloog_iv): Always use sufficiently large signed type (signed long long). If IV does not fit in signed long long, then bail safely out of graphite. * testsuite/gcc.dg/graphite/pr42644.c: New. --- gcc/ChangeLog.graphite | 9 +++++++ gcc/graphite-clast-to-gimple.c | 13 ++++++++-- gcc/testsuite/gcc.dg/graphite/pr42644.c | 43 +++++++++++++++++++++++++++++++++ 3 files changed, 63 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/graphite/pr42644.c diff --git a/gcc/ChangeLog.graphite b/gcc/ChangeLog.graphite index 300fb1674c6..9c00830a3d5 100644 --- a/gcc/ChangeLog.graphite +++ b/gcc/ChangeLog.graphite @@ -1,5 +1,14 @@ 2010-01-22 Ramakrishna Upadrasta + PR middle-end/42644 + PR middle-end/42130 + * graphite-clast-to-gimple.c (gcc_type_for_cloog_iv): Always use + sufficiently large signed type (signed long long). If IV does not + fit in signed long long, then bail safely out of graphite. + * testsuite/gcc.dg/graphite/pr42644.c: New. + +2010-01-22 Ramakrishna Upadrasta + * graphite-scop-detection.c (dot_all_scops): Make calls to dot run in background. diff --git a/gcc/graphite-clast-to-gimple.c b/gcc/graphite-clast-to-gimple.c index 73ffbbc897c..b12aac99214 100644 --- a/gcc/graphite-clast-to-gimple.c +++ b/gcc/graphite-clast-to-gimple.c @@ -541,14 +541,23 @@ gcc_type_for_cloog_iv (const char *cloog_iv, gimple_bb_p gbb) { struct ivtype_map_elt_s tmp; PTR *slot; + tree type; tmp.cloog_iv = cloog_iv; slot = htab_find_slot (GBB_CLOOG_IV_TYPES (gbb), &tmp, NO_INSERT); if (slot && *slot) - return ((ivtype_map_elt) *slot)->type; + { + type = ((ivtype_map_elt) *slot)->type; + if (TYPE_UNSIGNED (type) + && (TYPE_SIZE (type) == TYPE_SIZE (long_long_integer_type_node))) + { + gloog_error = true; + return type; + } + } - return integer_type_node; + return long_long_integer_type_node; } /* Returns the induction variable for the loop that gets translated to diff --git a/gcc/testsuite/gcc.dg/graphite/pr42644.c b/gcc/testsuite/gcc.dg/graphite/pr42644.c new file mode 100644 index 00000000000..5b371ba509c --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/pr42644.c @@ -0,0 +1,43 @@ +/* Testcase extracted from test 183.equake in SPEC CPU2000. */ +#include + +double Ke[2], ds[2]; + +void foo(double Ke[2], int i, double ds[], int column) +{ + double tt, ts; + unsigned long long j; + + for (j = 0; j < 2; j++) { + ++column; + ts = ds[i]; + if (i == j) + tt = 123; + else + tt = 0; + Ke[column] = Ke[column] + ts + tt; + } +} + + +int +main () +{ + int i, j; + + ds[0] = 1.0; + ds[1] = 1.0; + + foo(Ke, 0, ds, -1); + + for (i = 0; i < 1; i++) + { + for (j = 0; j < 2; j++) + printf ("%d ", (int) Ke[j]); + printf("# "); + } + + printf("\n"); + + return 0; +} -- 2.11.4.GIT