From patchwork Thu Aug 11 08:25:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 56691 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3BE8D385AE47 for ; Fri, 12 Aug 2022 09:04:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3BE8D385AE47 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1660295052; bh=78HwAQM6s3l2AuvQFOERZo/yNriGtFiuvN+nrznsEUo=; h=Resent-From:Resent-Date:Resent-To:Date:To:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:Cc:From; b=GtAxv8ijB4cZa2DsZXX52R78OwEN31Xik4B9CDkyNSAP/Rqyp0aZR6WuJrCxXc66w XqFveKYrkcyPD1r7kc7bS+/GH4q/e36Kl2HgBWjXrustLQTFlgyXIa/G4Snb5pefc9 9MVUf5f2W3hgD0szW7arOYkPhDf8n+bs1eKl7Ikk= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 64ABC3858CDA for ; Fri, 12 Aug 2022 09:03:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 64ABC3858CDA Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-444-K2IqzCrHMZWRnvkNzt2Bvg-1; Fri, 12 Aug 2022 05:03:40 -0400 X-MC-Unique: K2IqzCrHMZWRnvkNzt2Bvg-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 67F813C10172; Fri, 12 Aug 2022 09:03:40 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.41]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4FE0D112131B; Fri, 12 Aug 2022 09:03:39 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 27C93aEU3995543 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 12 Aug 2022 11:03:36 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 27C93Zfs3995542; Fri, 12 Aug 2022 11:03:35 +0200 Resent-From: Jakub Jelinek Resent-Date: Fri, 12 Aug 2022 11:03:35 +0200 Resent-Message-ID: Resent-To: Richard Biener , Aldy Hernandez , gcc-patches@gcc.gnu.org Date: Thu, 11 Aug 2022 10:25:42 +0200 To: Richard Biener , Aldy Hernandez Subject: [PATCH] phiopt: Remove unnecessary checks from spaceship_replacement [PR106506] Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_NONE, 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-Patchwork-Original-From: Jakub Jelinek via Gcc-patches From: Jakub Jelinek Reply-To: Jakub Jelinek Cc: gcc-patches@gcc.gnu.org Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" 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? 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. Jakub --- 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