[Bug tree-optimization/90571] Missed optimization opportunity when returning function pointers based on run-time boolean

vittorio.romeo at outlook dot com gcc-bugzilla@gcc.gnu.org
Thu May 23 13:18:00 GMT 2019


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

--- Comment #4 from Vittorio Romeo <vittorio.romeo at outlook dot com> ---
> I wonder how the "original" testcase looked
like - the one in this bug is probably simplified from real-world code?

This is what the original author of the code (Filipp Gelman) said:

> I was reviewing some code that checked configuration. The configuration struct has several functions taking no arguments and returning bool. The value of an enum determined which of these was called.
> I thought that the choice of which member function to call depends only on the enum and not on anything else in the configuration, so I tried splitting selecting the member function from calling it.
> This code looks much closer to what I reviewed: https://godbolt.org/z/L_W_oi
> The author wrote `test1`. I considered suggesting `test2`, but was surprised by it not optimizing to the same code.


More information about the Gcc-bugs mailing list