https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111459
--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> --- (In reply to Andrew Pinski from comment #3) > So on the trunk > > we have: > > Removing dead stmt:_39 = PHI <_12(5)> > > In ccp4 but we don't delete _12 as dead. > > Then dse deletes it: > Deleted trivially dead stmt: _12 = (int) _6; > > Let me look into that and see if there is a reason why _12 is not deleted > during ccp4. So what is happening is before ccp4 we have: ``` <bb 5> [local count: 805306368]: _12 = (int) _2; if (_12 > 1) goto <bb 9>; [78.67%] else goto <bb 6>; [21.33%] <bb 6> [local count: 536870912]: # _39 = PHI <_12(5)> if (_39 == 0) goto <bb 9>; [0.00%] else goto <bb 7>; [100.00%] <bb 7> [local count: 536870912]: if (_2 != 0) goto <bb 8>; [51.41%] else goto <bb 9>; [48.59%] <bb 8> [local count: 276026181]: # i.4_28 = PHI <i.0_1(7)> # m_23 = PHI <0(7)> # ivtmp_30 = PHI <3(7)> _38 = 0; _35 = 247; m_34 = -9; i.4_32 = i.0_1; _26 = 247; _17 = 238; m_5 = -18; ivtmp_6 = 1; i.4_44 = i.0_1; _47 = 238; _45 = 229; m_19 = -27; ivtmp_8 = 0; <bb 9> [local count: 1073741829]: return 0; ``` After we get: ``` <bb 5> [local count: 805306368]: _12 = (int) _2; if (_12 > 1) goto <bb 9>; [78.67%] else goto <bb 6>; [21.33%] <bb 6> [local count: 536870912]: if (_12 == 0) goto <bb 9>; [0.00%] else goto <bb 7>; [100.00%] <bb 7> [local count: 536870912]: if (_2 != 0) goto <bb 8>; [51.41%] else goto <bb 9>; [48.59%] <bb 8> [local count: 276026181]: <bb 9> [local count: 1073741829]: return 0; ``` And then cfgcleanup comes long and removes the bb7, bb6 and leaves bb5: ``` <bb 5> [local count: 805306368]: _12 = (int) _2; <bb 6> [local count: 1073741829]: return 0; ``` But if we are removing the if statements during cfgcleanup, maybe we should try to see if the uses have zero uses while doing the cleanup there too. Let me see if I can improve cfgcleanup then.