[Bug tree-optimization/43236] -ftree-loop-distribution produces wrong code in reload1.c:delete_output_reload(), bootstrap fails
--- Comment #9 from amonakov at gcc dot gnu dot org 2010-03-10 12:54 --- Subject: Bug 43236 Author: amonakov Date: Wed Mar 10 12:53:51 2010 New Revision: 157339 URL: http://gcc.gnu.org/viewcvs?root=gccview=revrev=157339 Log: 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. Added: trunk/gcc/testsuite/gcc.c-torture/execute/pr43236.c Modified: trunk/gcc/ChangeLog trunk/gcc/testsuite/ChangeLog trunk/gcc/tree-loop-distribution.c -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43236
[Bug tree-optimization/43236] -ftree-loop-distribution produces wrong code in reload1.c:delete_output_reload(), bootstrap fails
--- Comment #10 from amonakov at gcc dot gnu dot org 2010-03-10 12:57 --- Both issues are fixed with above commit. -- amonakov at gcc dot gnu dot org changed: What|Removed |Added Status|NEW |RESOLVED Resolution||FIXED http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43236
[Bug tree-optimization/43236] -ftree-loop-distribution produces wrong code in reload1.c:delete_output_reload(), bootstrap fails
--- Comment #11 from sezeroz at gmail dot com 2010-03-10 14:17 --- The testcase fails with 4.4 with -Ox -ftree-loop-distribution and the patch does not apply to 4.4. Will there be a gcc-4.4 backport of this? -- sezeroz at gmail dot com changed: What|Removed |Added CC||sezeroz at gmail dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43236
[Bug tree-optimization/43236] -ftree-loop-distribution produces wrong code in reload1.c:delete_output_reload(), bootstrap fails
--- Comment #8 from amonakov at gcc dot gnu dot org 2010-03-09 16:55 --- Given the fact that loop distribution only works for two-bb loops, I think the fix is to simply take number of latch executions when the stmt is in the latch. diff --git a/gcc/tree-loop-distribution.c b/gcc/tree-loop-distribution.c --- a/gcc/tree-loop-distribution.c +++ b/gcc/tree-loop-distribution.c @@ -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); } } } -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43236
[Bug tree-optimization/43236] -ftree-loop-distribution produces wrong code in reload1.c:delete_output_reload(), bootstrap fails
--- Comment #5 from rguenth at gcc dot gnu dot org 2010-03-03 10:38 --- Confirmed. -- rguenth at gcc dot gnu dot org changed: What|Removed |Added CC||spop at gcc dot gnu dot org Status|UNCONFIRMED |NEW Ever Confirmed|0 |1 Known to fail||4.4.3 4.5.0 Last reconfirmed|-00-00 00:00:00 |2010-03-03 10:38:17 date|| http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43236
[Bug tree-optimization/43236] -ftree-loop-distribution produces wrong code in reload1.c:delete_output_reload(), bootstrap fails
--- Comment #6 from amonakov at gcc dot gnu dot org 2010-03-03 13:06 --- Not a regression, off-by-one error in reverse iteration case is since day one. Patch: diff --git a/gcc/tree-loop-distribution.c b/gcc/tree-loop-distribution.c index 13ac7ea..110abdc 100644 --- a/gcc/tree-loop-distribution.c +++ b/gcc/tree-loop-distribution.c @@ -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); This fixes the -O[123] miscompilations. -Os is slightly harder to fix, since we use wrong number of iterations (cond bb is executed 11 times, latch bb with assignment 10 times). -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43236
[Bug tree-optimization/43236] -ftree-loop-distribution produces wrong code in reload1.c:delete_output_reload(), bootstrap fails
--- Comment #7 from amonakov at gcc dot gnu dot org 2010-03-03 13:38 --- (In reply to comment #6) This fixes the -O[123] miscompilations. -Os is slightly harder to fix, since we use wrong number of iterations (cond bb is executed 11 times, latch bb with assignment 10 times). I don't see what is the proper fix for the -Os problem. The loop structure is as follows: bb2 i = 20 goto bb4 bb3 i-- a[i] = 0 bb4 if (i 10) goto bb3 Thus, bb4 is header, bb3 is latch, number_of_exit_cond_executions() is 11, just_once_each_iteration_p() is true for both bb3 and bb4 (?!) -- amonakov at gcc dot gnu dot org changed: What|Removed |Added CC||amonakov at gcc dot gnu dot ||org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43236
[Bug tree-optimization/43236] -ftree-loop-distribution produces wrong code in reload1.c:delete_output_reload(), bootstrap fails
--- Comment #1 from zsojka at seznam dot cz 2010-03-02 20:20 --- Created an attachment (id=20005) -- (http://gcc.gnu.org/bugzilla/attachment.cgi?id=20005action=view) this patch causes bootstrap with BOOT_CFLAGS=-O2 -ftree-loop-distribution to assert Assert message is: /mnt/svn/gcc-trunk/libgcc/../gcc/libgcc2.c: In function #8216;__mulvdi3#8217;: /mnt/svn/gcc-trunk/libgcc/../gcc/libgcc2.c:400:1: internal compiler error: in delete_output_reload, at reload1.c:8543 Please submit a full bug report, with preprocessed source if appropriate. See http://gcc.gnu.org/bugs.html for instructions. which is: gcc_assert(spill_reg_store[last_reload_reg + k] == 0); -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43236
[Bug tree-optimization/43236] -ftree-loop-distribution produces wrong code in reload1.c:delete_output_reload(), bootstrap fails
--- Comment #2 from zsojka at seznam dot cz 2010-03-02 20:33 --- Created an attachment (id=20006) -- (http://gcc.gnu.org/bugzilla/attachment.cgi?id=20006action=view) this patch causes regular bootstrap to assert Assert message is: /mnt/svn/gcc-trunk/libgcc/../gcc/libgcc2.c: In function #8216;__mulvdi3#8217;: /mnt/svn/gcc-trunk/libgcc/../gcc/libgcc2.c:400:1: internal compiler error: in delete_output_reload, at reload1.c:8543 Please submit a full bug report, with preprocessed source if appropriate. See http://gcc.gnu.org/bugs.html for instructions. which is: gcc_assert(spill_reg_store[last_reload_reg + k] == 0); -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43236
[Bug tree-optimization/43236] -ftree-loop-distribution produces wrong code in reload1.c:delete_output_reload(), bootstrap fails
--- Comment #3 from zsojka at seznam dot cz 2010-03-03 06:26 --- Created an attachment (id=20008) -- (http://gcc.gnu.org/bugzilla/attachment.cgi?id=20008action=view) minimal executable testcase Fails when compiled with -ftree-loop-distribution at all -O[123s] levels: $ /mnt/svn/gcc-trunk/binary-157161/bin/gcc pr43236.c -O1 -ftree-loop-distribution ./a.out Aborted -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43236
[Bug tree-optimization/43236] -ftree-loop-distribution produces wrong code in reload1.c:delete_output_reload(), bootstrap fails
--- Comment #4 from zsojka at seznam dot cz 2010-03-03 06:30 --- (In reply to comment #3) When output is uncommented, -Os shows different behaviour than -O[123] (but still wrong): -Os zeroes items [8] - [18] -O[123] zeroes [9] - [18] expected is [10] - [19] -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43236