From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id C6921388E807; Thu, 17 Dec 2020 13:41:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C6921388E807 From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/94779] Bad optimization of simple switch Date: Thu, 17 Dec 2020 13:41:18 +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: 10.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: jakub 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, 17 Dec 2020 13:41:18 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D94779 --- Comment #15 from Jakub Jelinek --- (In reply to Martin Li=C5=A1ka from comment #14) > Ok, I've just taken look at what EVRP pass does before SWITCHCONV pass is > called. > I see that EVRP can properly prune dead cases of a switch, but it's not > perfect: >=20 > int f1(unsigned x) > { > if (x =3D=3D 2 || x =3D=3D 3 || x >=3D 5) > __builtin_unreachable (); > switch (x) > { > case 0: return 1; > case 1: return 2; > case 2: return 3; > case 3 ... 8: return 4; > } > } The old VRP/EVRP only tracks simple ranges and anti-ranges, so can't deal w= ith what you have above, the new ranger code can deal with multiple subranges, = but the question is if all the interfaces deal with those. > This seems to me like a strange EVRP transformation :/ Why? And, the user could have written it that way too.=