https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105158
Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Ever confirmed|0 |1 Status|UNCONFIRMED |NEW Summary|ftree-ccp drops DWARF const |ftree-ccp (CFG cleanup) |value attribute at |drops DWARF const value |-Og/-O1/-O2/-O3 |attribute at | |-Og/-O1/-O2/-O3 Severity|normal |enhancement Last reconfirmed| |2022-04-05 --- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> --- The issue is that the definition we put the debug stmt into is in <bb 2> : [t.c:4:5] # DEBUG BEGIN_STMT [t.c:4:16] # DEBUG l_174 => 0 [t.c:4:27] # DEBUG l_188 => 0 [t.c:4:38] # DEBUG l_191 => 0 [t.c:4:49] # DEBUG l_240 => 1 [t.c:5:5] # DEBUG BEGIN_STMT [t.c:6:5] # DEBUG BEGIN_STMT [t.c:6:20] # DEBUG l_169 => 0 [t.c:6:25] if (0 != 0) goto <bb 3>; [INV] else goto <bb 5>; [INV] <bb 5> : <bb 6> : [t.c:6:11] # DEBUG l_171 => 0 [t.c:7:5] # DEBUG BEGIN_STMT [t.c:7:5] goto <bb 8>; [INV] <bb 8> : # l_169_3 = PHI <[t.c:6:20] 0(6), [t.c:7:30] l_169_19(7)> # DEBUG l_169 => l_169_3 [t.c:7:18] # DEBUG BEGIN_STMT [t.c:7:18] if (l_169_3 <= 9) goto <bb 7>; [INV] else goto <bb 9>; [INV] and when CFG cleanup merges all the forwarders it finds no location to put the debug stmt to - it tries to move the debug stmts to the successor but that doesn't have a single predecessor so that's not a valid thing to do. Moving to the predecessor would be valid if that has a single successor though but that's not implemented. In this case the predecessor is block 2 at the point in question and it has a single successor plus the last stmt in it doesn't end the BB.