From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 367D1384144F; Tue, 21 Jun 2022 02:45:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 367D1384144F From: "luoxhu at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/105740] missed optimization switch transformation for conditions with duplicate conditions Date: Tue, 21 Jun 2022 02:45:07 +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.1.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: luoxhu 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: --- 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: Tue, 21 Jun 2022 02:45:07 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D105740 --- Comment #2 from luoxhu at gcc dot gnu.org --- Run if_to_switch and convert_switch again after copyprop2 could remove the redundant statement and expose opportunity for if-to-switch again, is this reasonable or just move if-to-switch/switch-conversion later run only once?= =20=20 diff --git a/gcc/gimple-if-to-switch.cc b/gcc/gimple-if-to-switch.cc index f7b0b02628b..8f55d0e2f75 100644 --- a/gcc/gimple-if-to-switch.cc +++ b/gcc/gimple-if-to-switch.cc @@ -484,6 +484,8 @@ public: || bit_test_cluster::is_enabled ()); } + opt_pass *clone () { return new pass_if_to_switch (m_ctxt); } + virtual unsigned int execute (function *); }; // class pass_if_to_switch diff --git a/gcc/passes.def b/gcc/passes.def index 375d3d62d51..b257307e085 100644 --- a/gcc/passes.def +++ b/gcc/passes.def @@ -243,6 +243,8 @@ along with GCC; see the file COPYING3. If not see Clean them up. Failure to do so well can lead to false positives from warnings for erroneous code. */ NEXT_PASS (pass_copy_prop); + NEXT_PASS (pass_if_to_switch); + NEXT_PASS (pass_convert_switch); /* Identify paths that should never be executed in a conforming program and isolate those paths. */ NEXT_PASS (pass_isolate_erroneous_paths); diff --git a/gcc/tree-switch-conversion.cc b/gcc/tree-switch-conversion.cc index 50a17927f39..d5c8262785e 100644 --- a/gcc/tree-switch-conversion.cc +++ b/gcc/tree-switch-conversion.cc @@ -2429,6 +2429,9 @@ public: /* opt_pass methods: */ virtual bool gate (function *) { return flag_tree_switch_conversion !=3D= 0; } + + opt_pass *clone () { return new pass_convert_switch (m_ctxt); } + virtual unsigned int execute (function *);=