From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 6DDC43858410; Mon, 25 Mar 2024 10:09:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6DDC43858410 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1711361397; bh=ZD+eMQ17Pz8dwSQEtwfXr8UuwetlRk8HkDZ2TlJ8bUg=; h=From:To:Subject:Date:From; b=peHfgm1Mv3NuL23IxGtQD98r8W5MXEysN8nR+OL2EnzVIJXZ97XEj22navAJmEldV d47J4bkaXNv5S+DJhvR8/HM+3g6WwrSw/YmcLSEWdzknmWoN0bLSAyJsCh7DkvgAl0 ZcEBre6EPiLWABMeoUeVp+5vgqy4mO1yMtQ0/R0s= From: "chfast at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug rtl-optimization/114452] New: Functions invoked through compile-time table of function pointers not inlined Date: Mon, 25 Mar 2024 10:09:56 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: rtl-optimization X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: chfast at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D114452 Bug ID: 114452 Summary: Functions invoked through compile-time table of function pointers not inlined Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: rtl-optimization Assignee: unassigned at gcc dot gnu.org Reporter: chfast at gmail dot com Target Milestone: --- In the following example there is a compile-time table of pointers to simple functions. When the table is used in a simple unrolled loop with constant t= rip count the functions invoked by pointers are not inlined. using F =3D int (*)(int) noexcept; void test(int z[2]) noexcept { static constexpr F fs[]{ [](int x) noexcept { return x; }, [](int x) noexcept { return x; }, }; for (int i =3D 0; i < 2; ++i) { z[i] =3D fs[i](z[i]); } } Generated assembly: test(int*)::{lambda(int)#1}::_FUN(int): mov eax, edi ret test(int*)::{lambda(int)#2}::_FUN(int): mov eax, edi ret test(int*): mov rdx, rdi mov edi, DWORD PTR [rdi] call test(int*)::{lambda(int)#1}::_FUN(int) mov edi, DWORD PTR [rdx+4] mov DWORD PTR [rdx], eax call test(int*)::{lambda(int)#2}::_FUN(int) mov DWORD PTR [rdx+4], eax ret https://godbolt.org/z/fGqPKh81j=