In http://gcc.gnu.org/wiki/Hot%20and%20Cold%20Partitioning, you wrote:
> Modifying the hot/cold partitioning optimization to make sure ALL the > hot blocks come before ALL the cold blocks in the RTL representation. > This in turn will allow for the elimination of the UNLIKELY notes in > each cold block; instead there will only need to be one note, at the > single transition from hot to cold (if there is one). This, in turn, > will allow the elimination of forward scanning in the instruction > stream to determine. for each individual BB, which section it belongs > in. All of this will also entail the introduction of a new function > "current_function_section" in addition to the current "function_section" > function, and the updates of some calls to "function_section" to be > calls to "current_function_section".
I think this is a bad idea.
consider: for (;;i++ ) { if (i == 1000) i = 0; /* do stuff... */ }
The "i = 0;" statement is in its own cold block. On a number of targets, a conditional jump can't reach the cold section, so you'd have to replace a condjump around a simple instruction by a condjump around an jump, which is likely larger, slower, and might even increase register pressure.