From patchwork Thu Oct 20 09:42:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 6110 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp7515wrr; Thu, 20 Oct 2022 02:57:51 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6/Ljdtv3ZudMZ9AJiC0FBTCyUlev5N/kck4CEHUXaM9xL9uJa017gJRrV6mLVzhSs6BwBH X-Received: by 2002:a17:907:97cc:b0:797:c389:de5f with SMTP id js12-20020a17090797cc00b00797c389de5fmr1874334ejc.627.1666259871479; Thu, 20 Oct 2022 02:57:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666259871; cv=none; d=google.com; s=arc-20160816; b=mSnpA9osGbK4yGIb/BJzhmiW/wfMDpTHwnKwOuaCYYq8jssJZ29e+oxgXmFOVNqjjj erulSBg11NXRYjjNIlMZrVFefy1wRQbXu7vUeA7U1jgln37CPJ94OcTFNmqT4o6MxTDr s/nEe3q0w/03wNdJWae3vAsfUMmzNEkJm9NW9/wzUtk6r6HGjM6jJ1Oc7mYvsSu/zALp 0Czag44aJakv3i+L/j319qpkVbmlXL8wB/WD0yGxmZ4ZjU/OYHw2VNifdwhr5RPFn9xr 4ILm+zyeCwOuBdKZsbbdjIpaHbK/EP3EZFRv7TmnHbp0rTRFoZ+67ySa9Iju/0OUxDC1 +8Ug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:mime-version :user-agent:message-id:date:subject:mail-followup-to:to:dmarc-filter :delivered-to:dkim-signature:dkim-filter; bh=F7G9Dj9qowuTrRRaN6VRzBdK+ATLqvHLXiBQgFC+g0M=; b=ymfv6SgTqDjC6C1Y9n81Nln4o5ozfVabeAXafprgOgiHOUtG5qQ3Q7Q3Vq3/nfZvwU rSl+NorXf/dlGXtf3Jf4YjKqTrX5R78cVrXmY6y1dAKEdkFpUwHni2EBvVT7waEA5SNH O36AMyx3stR9smQkLN8UIBxMY3CNbD9COQnL6+yB0KE38FuHKmvuSltBsq6czlIM6kcq fFVnFlrHyZYxWDBpJ2WbGvYhjaoY9TxujZ7CU93gZcYfOv+Av2paojzoH2EaFaqOXpbm kRnK+oLTy4Rl9HUOyQuh+KjFkjAZMsqgKCrAI2ZrH76aVU2X/2+XWVKlYkCuLn3xBIYj Ubzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=JOv6R+3t; 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 y4-20020a50eb84000000b0045a26e5d4b6si15097554edr.78.2022.10.20.02.57.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Oct 2022 02:57:51 -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=JOv6R+3t; 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 ECC0F380E3FD for ; Thu, 20 Oct 2022 09:43:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org ECC0F380E3FD DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1666259006; bh=F7G9Dj9qowuTrRRaN6VRzBdK+ATLqvHLXiBQgFC+g0M=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=JOv6R+3t+u2eLbshzM1OlTeJ1HX3I2Jn0L+puOYQ7FyTCEQMTmjzzWCL2cT5+6JiJ PbgbiQ8I5U3OWljUg4KjGxHv98lsfoSFlBpbgGDuojQUOYXyMnJygQ38K8FkVyU0Fk Lrx2GsJfnuiIOxE9fcidKF6lf+XcKRyaf92V+VJg= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by sourceware.org (Postfix) with ESMTP id 0BF52388883D for ; Thu, 20 Oct 2022 09:42:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 0BF52388883D Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 012341063 for ; Thu, 20 Oct 2022 02:42:47 -0700 (PDT) Received: from localhost (e121540-lin.manchester.arm.com [10.32.98.62]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 6690B3F792 for ; Thu, 20 Oct 2022 02:42:40 -0700 (PDT) To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@arm.com Subject: [pushed] aarch64: Commonise some folding code Date: Thu, 20 Oct 2022 10:42:39 +0100 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 X-Spam-Status: No, score=-43.7 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_NONE, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, TXREP 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: Richard Sandiford via Gcc-patches From: Richard Sandiford Reply-To: Richard Sandiford 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?1747200110982869047?= X-GMAIL-MSGID: =?utf-8?q?1747200110982869047?= Add an aarch64_sve::gimple_folder helper for folding calls to integer constants. SME will make more use of this. Tested on aarch64-linux-gnu & pushed. Richard gcc/ * config/aarch64/aarch64-sve-builtins.h (gimple_folder::fold_to_cstu): New member function. * config/aarch64/aarch64-sve-builtins.cc (gimple_folder::fold_to_cstu): Define. * config/aarch64/aarch64-sve-builtins-base.cc (svcnt_bhwd_impl::fold): Use it. --- gcc/config/aarch64/aarch64-sve-builtins-base.cc | 9 ++------- gcc/config/aarch64/aarch64-sve-builtins.cc | 7 +++++++ gcc/config/aarch64/aarch64-sve-builtins.h | 1 + 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/gcc/config/aarch64/aarch64-sve-builtins-base.cc b/gcc/config/aarch64/aarch64-sve-builtins-base.cc index 141f44d4d94..23b4d42822a 100644 --- a/gcc/config/aarch64/aarch64-sve-builtins-base.cc +++ b/gcc/config/aarch64/aarch64-sve-builtins-base.cc @@ -517,9 +517,7 @@ public: gimple * fold (gimple_folder &f) const override { - tree count = build_int_cstu (TREE_TYPE (f.lhs), - GET_MODE_NUNITS (m_ref_mode)); - return gimple_build_assign (f.lhs, count); + return f.fold_to_cstu (GET_MODE_NUNITS (m_ref_mode)); } rtx @@ -553,10 +551,7 @@ public: unsigned int elements_per_vq = 128 / GET_MODE_UNIT_BITSIZE (m_ref_mode); HOST_WIDE_INT value = aarch64_fold_sve_cnt_pat (pattern, elements_per_vq); if (value >= 0) - { - tree count = build_int_cstu (TREE_TYPE (f.lhs), value); - return gimple_build_assign (f.lhs, count); - } + return f.fold_to_cstu (value); return NULL; } diff --git a/gcc/config/aarch64/aarch64-sve-builtins.cc b/gcc/config/aarch64/aarch64-sve-builtins.cc index 63b1358c138..37228f6389a 100644 --- a/gcc/config/aarch64/aarch64-sve-builtins.cc +++ b/gcc/config/aarch64/aarch64-sve-builtins.cc @@ -2615,6 +2615,13 @@ gimple_folder::redirect_call (const function_instance &instance) return call; } +/* Fold the call to constant VAL. */ +gimple * +gimple_folder::fold_to_cstu (poly_uint64 val) +{ + return gimple_build_assign (lhs, build_int_cstu (TREE_TYPE (lhs), val)); +} + /* Fold the call to a PTRUE, taking the element size from type suffix 0. */ gimple * gimple_folder::fold_to_ptrue () diff --git a/gcc/config/aarch64/aarch64-sve-builtins.h b/gcc/config/aarch64/aarch64-sve-builtins.h index 63d1db776f7..0d130b871d0 100644 --- a/gcc/config/aarch64/aarch64-sve-builtins.h +++ b/gcc/config/aarch64/aarch64-sve-builtins.h @@ -500,6 +500,7 @@ public: tree load_store_cookie (tree); gimple *redirect_call (const function_instance &); + gimple *fold_to_cstu (poly_uint64); gimple *fold_to_pfalse (); gimple *fold_to_ptrue (); gimple *fold_to_vl_pred (unsigned int);