From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2153) id B11373858D28; Fri, 12 Aug 2022 11:41:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B11373858D28 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jakub Jelinek To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-2032] phiopt: Remove unnecessary checks from spaceship_replacement [PR106506] X-Act-Checkin: gcc X-Git-Author: Jakub Jelinek X-Git-Refname: refs/heads/master X-Git-Oldrev: 4cc0d3ebaee4b54280ff0466d8e5b351a3b5bacc X-Git-Newrev: 83e9bc792ef10d08bb952a961e8c6f567521d28d Message-Id: <20220812114116.B11373858D28@sourceware.org> Date: Fri, 12 Aug 2022 11:41:16 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 12 Aug 2022 11:41:16 -0000 https://gcc.gnu.org/g:83e9bc792ef10d08bb952a961e8c6f567521d28d commit r13-2032-g83e9bc792ef10d08bb952a961e8c6f567521d28d Author: Jakub Jelinek Date: Fri Aug 12 13:40:43 2022 +0200 phiopt: Remove unnecessary checks from spaceship_replacement [PR106506] Those 2 checks were just me trying to be extra careful, the (phires & 1) == phires and variants it is folded to of course make only sense for the -1/0/1/2 result spaceship, for -1/0/1 one can just use comparisons of phires. We only floating point spaceship if nans aren't honored, so the 2 case is ignored, and if it is, with Aldy's changes we can simplify the 2 case away from the phi but the (phires & 1) == phires stayed. It is safe to treat the phires comparison as phires >= 0 even then. 2022-08-12 Jakub Jelinek PR tree-optimization/106506 * tree-ssa-phiopt.cc (spaceship_replacement): Don't punt for is_cast or orig_use_lhs cases if phi_bb has 3 predecessors. * g++.dg/opt/pr94589-2.C: New test. Diff: --- gcc/testsuite/g++.dg/opt/pr94589-2.C | 2 +- gcc/tree-ssa-phiopt.cc | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/gcc/testsuite/g++.dg/opt/pr94589-2.C b/gcc/testsuite/g++.dg/opt/pr94589-2.C index 370deea9218..e9ef84b1912 100644 --- a/gcc/testsuite/g++.dg/opt/pr94589-2.C +++ b/gcc/testsuite/g++.dg/opt/pr94589-2.C @@ -1,7 +1,7 @@ // PR tree-optimization/94589 // { dg-do compile { target c++20 } } // { dg-options "-O2 -g0 -ffast-math -fdump-tree-optimized" } -// { dg-final { scan-tree-dump-times "\[ij]_\[0-9]+\\(D\\) (?:<|<=|==|!=|>|>=) \[ij]_\[0-9]+\\(D\\)" 12 "optimized" { xfail *-*-* } } } +// { dg-final { scan-tree-dump-times "\[ij]_\[0-9]+\\(D\\) (?:<|<=|==|!=|>|>=) \[ij]_\[0-9]+\\(D\\)" 12 "optimized" } } // { dg-final { scan-tree-dump-times "i_\[0-9]+\\(D\\) (?:<|<=|==|!=|>|>=) 5\\.0" 12 "optimized" } } #include diff --git a/gcc/tree-ssa-phiopt.cc b/gcc/tree-ssa-phiopt.cc index 0191b9cb254..d5f2ba8be1c 100644 --- a/gcc/tree-ssa-phiopt.cc +++ b/gcc/tree-ssa-phiopt.cc @@ -2448,8 +2448,6 @@ spaceship_replacement (basic_block cond_bb, basic_block middle_bb, return false; if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (orig_use_lhs)) return false; - if (EDGE_COUNT (phi_bb->preds) != 4) - return false; if (!single_imm_use (orig_use_lhs, &use_p, &use_stmt)) return false; @@ -2467,8 +2465,6 @@ spaceship_replacement (basic_block cond_bb, basic_block middle_bb, orig_use_lhs = gimple_assign_lhs (use_stmt); if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (orig_use_lhs)) return false; - if (EDGE_COUNT (phi_bb->preds) != 4) - return false; if (!single_imm_use (orig_use_lhs, &use_p, &use_stmt)) return false; }