From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 76468385783F; Fri, 18 Dec 2020 12:30:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 76468385783F From: "marxin at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/94779] Bad optimization of simple switch Date: Fri, 18 Dec 2020 12:30: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: 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: Fri, 18 Dec 2020 12:30:18 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D94779 --- Comment #21 from Martin Li=C5=A1ka --- > See my comment above. It isn't any integration of VRP, just asking the > ranger about the range, and it isn't useless because to be able to optimi= ze > properly, > you need to figure out for each value one of the 3 possibilities (handled > explicitly by switch and well defined, handled by default and never > reachable or UB). I've got the point that we have these 3 possibilities for each case. However, we also have it for "holes" which are removed and we can't disting= uish them in between __builtin_unreachable and falling to the default case. I believe a better place for Ranger is to improve: simplify_using_ranges::simplify_switch_using_ranges (gswitch *stmt) Note that even if CSWITCH does not do a transformation other passes can sti= ll benefit from a more canonical gswitch form. That said, I don't like the idea of using Ranger in cswitch because similar should do each pass that somehow works with switches.=