https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108351

--- Comment #5 from Martin Jambor <jamborm at gcc dot gnu.org> ---
If you rename main to something else, like bar, and so the calls to f
outside of the loop are not considered cold, you get the GCC 12
behavior.  Is this reduced from a real-world problem?

Because on the testcase IPA-CP actually does what I would like it to
do, it iginores the first parameter because really IPA-SRA is better
placed to deal with it and then does not duplicate f for the cold
calls.

The fact that the GCC 12 heuristics first cloned for a constant in a
useless parameter in the loop and then, when removing it in the other
calls, it happened to find out that those two share the same constant
in the second parameter, which happened to make the function shorter,
is basically luck rather than design.

Reply via email to