Fix PR43065: Insert bounds on pointer type parameters.
authorSebastian Pop <sebastian.pop@amd.com>
Mon, 8 Mar 2010 17:49:57 +0000 (17:49 +0000)
committerSebastian Pop <spop@gcc.gnu.org>
Mon, 8 Mar 2010 17:49:57 +0000 (17:49 +0000)
2010-03-05  Sebastian Pop  <sebastian.pop@amd.com>
    Reza Yazdani  <reza.yazdani@amd.com>

PR middle-end/43065
* graphite-sese-to-poly.c (add_param_constraints): Insert bounds
on pointer type parameters.

* gcc.dg/graphite/run-id-4.c: New.

Co-Authored-By: Reza Yazdani <reza.yazdani@amd.com>
From-SVN: r157289

gcc/ChangeLog.graphite
gcc/graphite-sese-to-poly.c
gcc/testsuite/gcc.dg/graphite/run-id-4.c [new file with mode: 0644]

index 4d2853ca44e24d8593dca794fddafa6b211edf6b..c3d82202becab82435adadd513c611f03ed2aad6 100644 (file)
@@ -1,4 +1,13 @@
-2010-03-04  Sebastian Pop  <sebastian.pop@amd.com>
+2010-03-05  Sebastian Pop  <sebastian.pop@amd.com>
+           Reza Yazdani  <reza.yazdani@amd.com>
+
+       PR middle-end/43065
+       * graphite-sese-to-poly.c (add_param_constraints): Insert bounds
+       on pointer type parameters.
+
+       * gcc.dg/graphite/run-id-4.c: New.
+
+2010-03-05  Sebastian Pop  <sebastian.pop@amd.com>
 
        PR middle-end/43065
        * gcc.dg/graphite/run-id-3.c: New.
index 279a905764dfb07062e3fb5bd09cf08184ca218d..89330727337d9e758ef1afb672e2fbe92e492764 100644 (file)
@@ -1499,13 +1499,19 @@ add_param_constraints (scop_p scop, ppl_Polyhedron_t context, graphite_dim_t p)
   ppl_Linear_Expression_t le;
   tree parameter = VEC_index (tree, SESE_PARAMS (SCOP_REGION (scop)), p);
   tree type = TREE_TYPE (parameter);
-  tree lb, ub;
+  tree lb = NULL_TREE;
+  tree ub = NULL_TREE;
 
-  if (!INTEGRAL_TYPE_P (type))
-    return;
-
-  lb = TYPE_MIN_VALUE (type);
-  ub = TYPE_MAX_VALUE (type);
+  if (INTEGRAL_TYPE_P (type))
+    {
+      lb = TYPE_MIN_VALUE (type);
+      ub = TYPE_MAX_VALUE (type);
+    }
+  else if (POINTER_TYPE_P (type))
+    {
+      lb = TYPE_MIN_VALUE (unsigned_type_node);
+      ub = TYPE_MAX_VALUE (unsigned_type_node);
+    }
 
   if (lb)
     {
diff --git a/gcc/testsuite/gcc.dg/graphite/run-id-4.c b/gcc/testsuite/gcc.dg/graphite/run-id-4.c
new file mode 100644 (file)
index 0000000..143a449
--- /dev/null
@@ -0,0 +1,28 @@
+/* PR rtl-optimization/24899 */
+
+extern void abort (void);
+
+__attribute__ ((noinline)) int
+foo (int x, int y, int *z)
+{
+  int a, b, c, d;
+
+  a = b = 0;
+  for (d = 0; d < y; d++)
+    {
+      if (z)
+       b = d * *z;
+      for (c = 0; c < x; c++)
+       a += b;
+    }
+
+  return a;
+}
+
+int
+main (void)
+{
+  if (foo (3, 2, 0) != 0)
+    abort ();
+  return 0;
+}