------- 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

Reply via email to