Quoting Richard Guenther <richard.guent...@gmail.com>:
the function implementation is odd. cost is always 1 when used, and both memory loads and calls are always cheap, but for example casts are not? Isn't return EDGE_COUNT (block->preds) * cost >= inserts_needed; always true? Or is inserts_needed not what it suggests?
The cost calculation and use is not an exact model of anything, but only a rough approximation, and thus, like any heuristic, should be considered subject to potential change when it can be shown that a change is beneficial in general. The idea was to write the code that changes to the cost calculation and use could be applied with ease. OTOH such changes shouldn't be adopted just because it looks like they'll make a more realistic mode, there should be some evidence that they make the compiler better in general.