Bootstrapped on x86_64-unknown-linux-gnu, testing in progress. Richard.
2017-10-20 Richard Biener <rguent...@suse.de> PR tree-optimization/82473 * tree-if-conv.c (predicate_mem_writes): Make sure to only remove false predicated stores. * gcc.dg/torture/pr82603.c: New testcase. Index: gcc/tree-if-conv.c =================================================================== --- gcc/tree-if-conv.c (revision 253926) +++ gcc/tree-if-conv.c (working copy) @@ -2214,7 +2214,8 @@ predicate_mem_writes (loop_p loop) { if (!gimple_assign_single_p (stmt = gsi_stmt (gsi))) ; - else if (is_false_predicate (cond)) + else if (is_false_predicate (cond) + && gimple_vdef (stmt)) { unlink_stmt_vdef (stmt); gsi_remove (&gsi, true); Index: gcc/testsuite/gcc.dg/torture/pr82603.c =================================================================== --- gcc/testsuite/gcc.dg/torture/pr82603.c (nonexistent) +++ gcc/testsuite/gcc.dg/torture/pr82603.c (working copy) @@ -0,0 +1,24 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-ftree-loop-vectorize" } */ + +int +mr (unsigned int lf, int ms) +{ + unsigned int sw = 0; + char *cu = (char *)&ms; + + while (ms < 1) + { + if (lf == 0) + ms = 0; + else + ms = 0; + ms += ((lf > 0) && ((lf > sw) ? 1 : ++*cu)); + } + + if (lf != 0) + cu = (char *)&sw; + *cu = lf; + + return ms; +}