]> git.ipfire.org Git - thirdparty/gcc.git/commit
Update profile in tree-ssa-dce
authorJan Hubicka <hubicka@ucw.cz>
Mon, 6 Oct 2025 19:35:22 +0000 (21:35 +0200)
committerJan Hubicka <hubicka@ucw.cz>
Mon, 6 Oct 2025 19:35:22 +0000 (21:35 +0200)
commit075310d3a3ef1a8b483b62d9535887b37f291ee4
tree0ccc6c7c73b626d01f7d75be9beb586373983011
parente04e815708789c8c2675742b323ba28786527640
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.
gcc/tree-cfgcleanup.cc
gcc/tree-ssa-dce.cc