https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114452
--- Comment #3 from Xi Ruoyao <xry111 at gcc dot gnu.org> ---
(In reply to Paweł Bylica from comment #2)
> I don't think this is related to lambdas. The following is also not
> optimized:
>
>
> using F = int (*)(int) noexcept;
>
> inline int impl(int x) noexcept { return x; }
>
> void test(int z[2]) noexcept {
> static constexpr F fs[]{
> impl,
> impl,
> };
>
> for (int i = 0; i < 2; ++i) {
> z[i] = fs[i](z[i]);
> }
> }
>
> https://godbolt.org/z/9hPbzo4Px
The analysis of PR111573 says:
"So we fail to inline since ipa-prop fails to track the constant function
address. I think this is really common in typical lambda function usage"
"fails to track the constant function address" applies for normal functions
too.