Hi, On Fri, 8 Jul 2011, Paulo J. Matos wrote:
> gcc4.5.3 hits continue the first time it gets there and gcc4.6.1 fails > the inner if and enters expand_gimple_stmt twice. Yes, the MEMREF branch merge disabled TER (temporary expression replacement, tree-ssa-ter.c) for loads with stores that possibly alias, because expand doesn't deal correctly with all cases. Without TERing these two instructions expand won't see both memory references at the same time, and hence generate separate load and store instruction, instead of a mem-mem move if that's supported on your target (I assume so, otherwise you wouldn't have noticed). The question is, why doesn't combine merge the two separate load and store insns again into one? If you feel adventurous you can try with the below patch. Test it also with the following testcase: --------------------------- char str[9] = "1234"; void bar (void) { unsigned int temp; char *p = &str[2]; memcpy (&temp, &str[1], 4); memcpy (p, &temp, 4); } --------------------------- If expand still has the problem and you apply the patch, then on some targets this will emit wrong instructions because the two sides of the MEM-MEM assignment implicitely constructed and given to expand will partially overlap. Ciao, Michael. -- Index: tree-ssa-ter.c =================================================================== --- tree-ssa-ter.c (revision 175921) +++ tree-ssa-ter.c (working copy) @@ -638,6 +638,7 @@ find_replaceable_in_bb (temp_expr_table_ is a load aliasing it avoid creating overlapping assignments which we cannot expand correctly. */ if (gimple_vdef (stmt) + && 0 && gimple_assign_single_p (stmt)) { gimple def_stmt = SSA_NAME_DEF_STMT (use);