From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id 4C38F3858280 for ; Fri, 12 Aug 2022 10:58:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4C38F3858280 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 37B323F79C; Fri, 12 Aug 2022 10:58:25 +0000 (UTC) Received: from wotan.suse.de (wotan.suse.de [10.160.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 30F712C141; Fri, 12 Aug 2022 10:58:25 +0000 (UTC) Date: Fri, 12 Aug 2022 10:58:25 +0000 (UTC) From: Richard Biener To: Jakub Jelinek cc: Aldy Hernandez , gcc-patches@gcc.gnu.org Subject: Re: [PATCH] phiopt: Remove unnecessary checks from spaceship_replacement [PR106506] In-Reply-To: Message-ID: References: User-Agent: Alpine 2.22 (LSU 394 2020-01-19) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-5.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 12 Aug 2022 10:58:27 -0000 On Thu, 11 Aug 2022, Jakub Jelinek wrote: > Hi! > > 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. > > Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? OK. Thanks, Richard. > 2022-08-11 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. > > --- gcc/tree-ssa-phiopt.cc.jj 2022-08-10 09:06:53.000000000 +0200 > +++ gcc/tree-ssa-phiopt.cc 2022-08-10 15:33:32.414641593 +0200 > @@ -2448,8 +2448,6 @@ spaceship_replacement (basic_block cond_ > 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_ > 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; > } > --- gcc/testsuite/g++.dg/opt/pr94589-2.C.jj 2022-08-10 09:06:52.921213966 +0200 > +++ gcc/testsuite/g++.dg/opt/pr94589-2.C 2022-08-10 15:45:24.599319922 +0200 > @@ -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 > > Jakub > > -- Richard Biener SUSE Software Solutions Germany GmbH, Frankenstrasse 146, 90461 Nuernberg, Germany; GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman; HRB 36809 (AG Nuernberg)