OSDN Git Service

PR tree-optimization/36038
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 24 Oct 2008 13:57:43 +0000 (13:57 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 24 Oct 2008 13:57:43 +0000 (13:57 +0000)
* tree-ssa-loop-ivopts.c (add_old_iv_candidates): For pointer bases
add sizetype IV with initial value zero instead of pointer type.

* gcc.c-torture/compile/pr36038.c: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@141343 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/pr36038.c [new file with mode: 0644]
gcc/tree-ssa-loop-ivopts.c

index 18b0e80..ef9bfbc 100644 (file)
@@ -1,3 +1,9 @@
+2008-10-24  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/36038
+       * tree-ssa-loop-ivopts.c (add_old_iv_candidates): For pointer bases
+       add sizetype IV with initial value zero instead of pointer type.
+
 2008-10-24  Manuel López-Ibáñez  <manu@gcc.gnu.org>
 
        PR c/7543
index bf56e53..9f82df3 100644 (file)
@@ -1,3 +1,8 @@
+2008-10-24  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/36038
+       * gcc.c-torture/compile/pr36038.c: New test.
+
 2008-10-24  Manuel López-Ibáñez  <manu@gcc.gnu.org>
 
        PR c/7543
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr36038.c b/gcc/testsuite/gcc.c-torture/compile/pr36038.c
new file mode 100644 (file)
index 0000000..de4bef3
--- /dev/null
@@ -0,0 +1,43 @@
+/* PR tree-optimization/36038 */
+
+long long list[10];
+long long expect[10] = { 0, 1, 2, 3, 4, 4, 5, 6, 7, 9 };
+long long *stack_base;
+int indices[10];
+int *markstack_ptr;
+
+void
+doit (void)
+{
+  long long *src;
+  long long *dst;
+  long long *sp = stack_base + 5;
+  int diff = 2;
+  int shift;
+  int count;
+
+  shift = diff - (markstack_ptr[-1] - markstack_ptr[-2]);
+  count = (sp - stack_base) - markstack_ptr[-1] + 2;
+  src = sp;
+  dst = (sp += shift);
+  while (--count)
+    *dst-- = *src--;
+}
+
+int
+main ()
+{
+  int i;
+  for (i = 0; i < 10; i++)
+    list[i] = i;
+
+  markstack_ptr = indices + 9;
+  markstack_ptr[-1] = 2;
+  markstack_ptr[-2] = 1;
+
+  stack_base = list + 2;
+  doit ();
+  if (__builtin_memcmp (expect, list, sizeof (list)))
+    __builtin_abort ();
+  return 0;
+}
index 628d426..92d9c75 100644 (file)
@@ -2228,9 +2228,11 @@ add_old_iv_candidates (struct ivopts_data *data, struct iv *iv)
   add_candidate (data, iv->base, iv->step, true, NULL);
 
   /* The same, but with initial value zero.  */
-  add_candidate (data,
-                build_int_cst (TREE_TYPE (iv->base), 0),
-                iv->step, true, NULL);
+  if (POINTER_TYPE_P (TREE_TYPE (iv->base)))
+    add_candidate (data, size_int (0), iv->step, true, NULL);
+  else
+    add_candidate (data, build_int_cst (TREE_TYPE (iv->base), 0),
+                  iv->step, true, NULL);
 
   phi = SSA_NAME_DEF_STMT (iv->ssa_name);
   if (gimple_code (phi) == GIMPLE_PHI)