https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111294
--- Comment #8 from Richard Biener <rguenth at gcc dot gnu.org> --- (In reply to Andrew Pinski from comment #7) > Created attachment 55892 [details] > version of using simple_dce_from_worklist in forwprop > > This is a version of using simple_dce_from_worklist in forwprop I had tried > at one point, but I don't remember why I did finish up this patch. That wouldn't catch the case in question. The issue is when we simplify _32 = (char) _31; - _4 = (unsigned char) _32; + _4 = (unsigned char) _31; we don't realize _32 becomes unused. I think it might be enough to add all original SSA uses of a stmt we fold to the DCE worklist if we simplified it (and also before substituting from the fwprop lattice?). I think it doesn't work to look at orig_stmt operands before we do update_stmt on the new stmt. Sth like the attached works though.