------- Comment #4 from steven at gcc dot gnu dot org 2010-01-30 16:51 ------- Eh, ignore comment #3. My understanding of CD-DCE really *is* rusty :-).
Being more careful now: IIRC the statement "j = 0" would have been control dependent on "if (b)" and marking "j = 0" would result in marking "if (b)" necessary. But since the value "0" is propagated into the PHI, there is no statement left to mark "if (b)" necessary. So ignoring the edge with the constant (like the very wrong patch of comment #3) results in *nothing* needing "if (b)" anymore. So the function is incorrectly transformed to just "return j". What is necessary here, is a reason to mark "if (b)" necessary, but not the loop. But since the loop now falls through directly to the PHI for "j_1", I don't see how... -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42906