Hi, The inlininer likes to recreate some MEM_REF, it copies most of the bits (TREE_THIS_NOTRAP, TREE_THIS_VOLATILE, etc.) but forgets about TREE_SIDE_EFFECTS. This causes the strlen optimization to think the memory store does not have a side effects.
OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions. Thanks, Andrew Pinski ChangeLog: * tree-inline.c (remap_gimple_op_r): Copy TREE_SIDE_EFFECTS also. testsuite/ChangeLog: * gcc.dg/tree-ssa/strlen-1.c: New testcase.
Index: testsuite/gcc.c-torture/compile/pr49474.c =================================================================== --- testsuite/gcc.c-torture/compile/pr49474.c (revision 0) +++ testsuite/gcc.c-torture/compile/pr49474.c (revision 0) @@ -0,0 +1,16 @@ +typedef struct gfc_formal_arglist +{ + int next; +} +gfc_actual_arglist; +update_arglist_pass (gfc_actual_arglist* lst, int po, unsigned argpos, + const char *name) +{ + ((void)(__builtin_expect(!(argpos > 0), 0) ? __builtin_unreachable(), 0 : 0)); + if (argpos == 1) + return 0; + if (lst) + lst->next = update_arglist_pass (lst->next, po, argpos - 1, name); + else + lst = update_arglist_pass (((void *)0), po, argpos - 1, name); +} Index: cprop.c =================================================================== --- cprop.c (revision 176187) +++ cprop.c (working copy) @@ -1332,7 +1332,7 @@ find_implicit_sets (void) FOR_EACH_BB (bb) { /* Check for more than one successor. */ - if (! EDGE_COUNT (bb->succs) > 1) + if (EDGE_COUNT (bb->succs) <= 1) continue; cond = fis_get_condition (BB_END (bb));