From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 1EF6F3858D35; Thu, 25 Nov 2021 18:19:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1EF6F3858D35 From: "marxin at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/103429] Optimization of Auto-generated condition chain is not giving good lookup tables. Date: Thu, 25 Nov 2021 18:19:40 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: marxin at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: marxin at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 25 Nov 2021 18:19:40 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D103429 --- Comment #4 from Martin Li=C5=A1ka --- So it's very funny what's happening here. iftoswitch pass is called for all e.g. f_dispatch_always_inline<10>, f_dispatch_always_inline<9> and so on until f_dispatch_always_inline<5> which is converted to switch. And then all early passes are called for f_dispatch_always_inline<4> which include einline and we end up with: __attribute__((always_inline)) void f_dispatch_always_inline<4> (int i) { : if (i_2(D) =3D=3D 4) goto ; [INV] else goto ; [INV] : f<4> (); goto ; [INV] : switch (i_2(D)) [16.67%], case 5: [16.67%], case 6: <= L4> [16.67%], case 7: [16.67%], case 8: [16.67%], case 9: [16.67= %]> : : f<5> (); goto ; [100.00%] : : f<6> (); goto ; [100.00%] : : f<7> (); goto ; [100.00%] : : f<8> (); goto ; [100.00%] : : f<9> (); : : return; } which is a mixture of if and switch statements. So what we basically need is if-to-switch hybrid support for if-else chain combined with switches.=