From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 8AFDE3858423; Fri, 2 Dec 2022 15:17:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8AFDE3858423 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1669994237; bh=qo5MC/kuab+Zq6PYyE5wMGbNPK6+eL0OuEFZLs07VhU=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Ud+3aegB4v/cUoACP4tL8AagPY5goXmlr5BMmBxytgbmgq1wWK1WD0AYFazM4ykH+ uOTkPbwswVBJ5efmEU2HvPM4DKXhZlDmv0v/cMKyNkxTkDdIsyGhUbH29H6O+eTQ3w p5vwTIHIMkdKUZpalZJous/rbXVDwL22uyk61C64= From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/107767] [13 Regression] switch to table conversion happening even though using btq is better Date: Fri, 02 Dec 2022 15:17:17 +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: 13.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: jakub at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 13.0 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D107767 --- Comment #9 from Jakub Jelinek --- Indeed, comparing that to int firewall3(const uint8_t *restrict data) { const uint16_t dst_port =3D *((const uint16_t *)data + 32); switch (dst_port) { case 15: return 1; case 23: return 1; case 47: return 1; case 45: return 1; case 42: return 1; case 1: return 1; case 2: return 1; case 3: return 1; default: return 0; } } this one is optimized correctly. In iftoswitch dump this one is much simpler though: dst_port_6 =3D MEM[(const uint16_t *)data_4(D) + 64B]; switch (dst_port_6) [INV], case 1 ... 3: [INV], case= 15: [INV], case 23: [INV], case 42: [INV], case 45: [IN= V], case 47: [INV]> : : : # _3 =3D PHI <1(2), 0(3)> : return _3; vs. dst_port_5 =3D MEM[(const uint16_t *)data_3(D) + 64B]; switch (dst_port_5) [INV], case 1: [INV], case 2: <= L23> [INV], case 3: [INV], case 15: [INV], case 23: [INV], case 42: [INV], case 45: [INV], case 47: [INV]> : : // predicted unlikely by early return (on trees) predictor. goto ; [INV] : : // predicted unlikely by early return (on trees) predictor. goto ; [INV] : : // predicted unlikely by early return (on trees) predictor. goto ; [INV] : : // predicted unlikely by early return (on trees) predictor. goto ; [INV] : : // predicted unlikely by early return (on trees) predictor. goto ; [INV] : : // predicted unlikely by early return (on trees) predictor. goto ; [INV] : : // predicted unlikely by early return (on trees) predictor. goto ; [INV] : : // predicted unlikely by early return (on trees) predictor. : # _2 =3D PHI <1(4), 1(5), 1(3), 1(10), 1(9), 1(8), 1(7), 1(6), 0(2)> : return _2; but I guess switchconv should be able to handle both the same.=