Commit 6edd8198 by Alexander Monakov Committed by Alexander Monakov

re PR tree-optimization/43236 (-ftree-loop-distribution produces wrong code in…

re PR tree-optimization/43236 (-ftree-loop-distribution produces wrong code in reload1.c:delete_output_reload(), bootstrap fails)

        PR tree-optimization/43236
        * tree-loop-distribution.c (generate_memset_zero): Fix off-by-one
        error in calculation of base address in reverse iteration case.
        (generate_builtin): Take number of latch executions if the statement
        is in the latch.
    
        * gcc.c-torture/execute/pr43236.c: New.

From-SVN: r157339
parent 9f698956
2010-03-10 Alexander Monakov <amonakov@ispras.ru>
PR tree-optimization/43236
* tree-loop-distribution.c (generate_memset_zero): Fix off-by-one
error in calculation of base address in reverse iteration case.
(generate_builtin): Take number of latch executions if the statement
is in the latch.
2010-03-10 Andrey Belevantsev <abel@ispras.ru>
PR middle-end/42859
......
2010-03-10 Alexander Monakov <amonakov@ispras.ru>
PR tree-optimization/43236
* gcc.c-torture/execute/pr43236.c: New test.
2010-03-10 Andrey Belevantsev <abel@ispras.ru>
PR middle-end/42859
......
/* { dg-options "-ftree-loop-distribution" } */
extern void abort(void);
extern void *memset(void *s, int c, __SIZE_TYPE__ n);
extern int memcmp(const void *s1, const void *s2, __SIZE_TYPE__ n);
/*extern int printf(const char *format, ...);*/
int main()
{
char A[30], B[30], C[30];
int i;
/* prepare arrays */
memset(A, 1, 30);
memset(B, 1, 30);
for (i = 20; i-- > 10;) {
A[i] = 0;
B[i] = 0;
}
/* expected result */
memset(C, 1, 30);
memset(C + 10, 0, 10);
/* show result */
/* for (i = 0; i < 30; i++)
printf("%d %d %d\n", A[i], B[i], C[i]); */
/* compare results */
if (memcmp(A, C, 30) || memcmp(B, C, 30)) abort();
return 0;
}
......@@ -285,6 +285,8 @@ generate_memset_zero (gimple stmt, tree op0, tree nb_iter,
addr_base = fold_convert_loc (loc, sizetype, addr_base);
addr_base = size_binop_loc (loc, MINUS_EXPR, addr_base,
fold_convert_loc (loc, sizetype, nb_bytes));
addr_base = size_binop_loc (loc, PLUS_EXPR, addr_base,
TYPE_SIZE_UNIT (TREE_TYPE (op0)));
addr_base = fold_build2_loc (loc, POINTER_PLUS_EXPR,
TREE_TYPE (DR_BASE_ADDRESS (dr)),
DR_BASE_ADDRESS (dr), addr_base);
......@@ -389,6 +391,8 @@ generate_builtin (struct loop *loop, bitmap partition, bool copy_p)
goto end;
write = stmt;
if (bb == loop->latch)
nb_iter = number_of_latch_executions (loop);
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment