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: 479 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6a10:38f:b0:2d5:3c95:9e21 with SMTP id 15csp733129pxh; Fri, 12 Aug 2022 02:04:38 -0700 (PDT) X-Google-Smtp-Source: AA6agR5a3On7dLsJWEiGYtcJZ7HGgssLTjOBDIZm4Iffmn/vLWW/PkWlVm/q4+gkZrVIo81L1ueX X-Received: by 2002:a17:907:284a:b0:731:5a2f:655a with SMTP id el10-20020a170907284a00b007315a2f655amr1999615ejc.403.1660295078772; Fri, 12 Aug 2022 02:04:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660295078; cv=none; d=google.com; s=arc-20160816; b=FS7jPAh3ED0FIAQvViZ/FQC1DRoafHk9rX1Sgia2/JqgKj0GDQtPG6qHWvxa1XzxiJ hub5xl3GgtGqaxnrnjGxW1Alj/V8KH0axxhmKFargfOXrRDxg9kUoWRXMGv2wsYKeQvt proBBjsEgiECNCBigzH66qMX0VK0nnip4+6dUGAGPZA83ISOQ1Eo8ZZZfTYSjpnJgcML aPJBnGxMeq7K60sfzhT8UcG049vICedGcQtnur6e1dCnSz0FApYpJUpYpHTcOo7jOT7s prvz7m3xYzCRDzT3GFMn2v4WMUOJklo21YIlypR4p34w9N+bu8Oj6b5QhDsCGJg0nVtM aXbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:reply-to:from:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :content-disposition:mime-version:message-id:subject:to:date :resent-to:resent-message-id:resent-date:resent-from:dmarc-filter :delivered-to:dkim-signature:dkim-filter; bh=78HwAQM6s3l2AuvQFOERZo/yNriGtFiuvN+nrznsEUo=; b=TnewddeV+l4Qw0NX+FCXm5fNmra84cOJRfhj+m9osZbopnLv+H5eEx9dygwG8aBqn6 4fBXlmC0EPWXcfu9DoTtABxiB5XVKRZWkJNn4JhFdk4YAH81RMuMG7Fz1zfrfbAeE6KV r+ATDgAecNgbq2BJ9SggCl529x3HsKMdRYuxuAaI3CRQQZlJbtMqOVxpbJ8LxLX+UET4 wnOO2Xs7FU+Zr4/T/pXqut1ejQWDUrt9dtZIDDAlExbaGz9Yta9RzVJD5EdOBBxKu9Tz qB7yvJ/gJlwF+0nrjUam5/mAZPVtzZrw5TAX2h66ANg+ep+M+aRSSfDfIWd/1rp+ev2M S21Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="hnbN3R/C"; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id qa7-20020a170907868700b0073092b8be95si1406451ejc.705.2022.08.12.02.04.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Aug 2022 02:04:38 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="hnbN3R/C"; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 51747385B83E for ; Fri, 12 Aug 2022 09:04:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 51747385B83E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1660295066; 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=hnbN3R/CcrVd1E7mJrAsf0erhXOGVsYtTZbWCKgxJSqvdwtPfmVNpICtsEWOaCSEj EI9YBD0Kg/oc+sMHIrG6+4QydsWt1gA04reV2WhIpbPkT4br/GlkNtbn3k1lWEwHrY b9OghHZ0ERU5lDR5u7a0yX72SAufcOZ/511UMysk= 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+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1740945572427049026?= X-GMAIL-MSGID: =?utf-8?q?1740945572427049026?= 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