https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122122
--- Comment #8 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Jan Hubicka <[email protected]>: https://gcc.gnu.org/g:075310d3a3ef1a8b483b62d9535887b37f291ee4 commit r16-4255-g075310d3a3ef1a8b483b62d9535887b37f291ee4 Author: Jan Hubicka <[email protected]> Date: Mon Oct 6 21:35:22 2025 +0200 Update profile in tree-ssa-dce The profile mismatches uncovered by my merge_blocks change are actually caused by tree-ssa-dce not updating profile of blocks with no statements for whose it optimized away control dependencies. In most cases those basic blocks are merged or skipped as forwarders. I tried to simply set their count as uninitialized but that upsets verifier since in some cases we keep the block around (for example, when it is header of a loop). In all cases I debugged we optimized away an unnecesary loop and while merging old code picked porfile of loop preheader, while we now pick loop header. This is however not guaranteed and we may process blocks in different order and pick wrong profile. Since regions of dead basic blocks must be acyclic it is easy to propagate the frequencies as implemented by this patch. Bootstrapped/regtested x86_64-linux. Comitted gcc/ChangeLog: PR middle-end/122122 * tree-cfgcleanup.cc (tree_forwarder_block_p): Cleanup. * tree-ssa-dce.cc (propagate_counts): New function. (eliminate_unnecessary_stmts): Use it.
