* 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
+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
+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
--- /dev/null
+/* 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;
+}
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)