From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1130) id B5DA7384B82B; Thu, 20 Oct 2022 09:38:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B5DA7384B82B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1666258705; bh=H0syp+0A9m+PHBlQhHXInycYGcDI+bIg4lQ7asFSuhI=; h=From:To:Subject:Date:From; b=dKVHLOcQGj1+8gvFRZWFx28bm6qcHMiCpozEHPJCN115FN7l2xYP2eXMRstYKA4dU 5NYuq8Tw915imW8tbt+he5GJzVcBPT8+kKVE+Z5RprgjmBYzREMCIo51NELHQtvq8g +VvzhsYAUxa2prJCw0spC+2oDsvGrK0TiQD5F1Wg= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Richard Sandiford To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-3402] aarch64: Commonise some folding code X-Act-Checkin: gcc X-Git-Author: Richard Sandiford X-Git-Refname: refs/heads/trunk X-Git-Oldrev: 7bca7218ac92b8f842d93dd672385c2ba0f8faf9 X-Git-Newrev: df99e9e42094dee0833ac38f53e7fae09b4d133c Message-Id: <20221020093825.B5DA7384B82B@sourceware.org> Date: Thu, 20 Oct 2022 09:38:25 +0000 (GMT) List-Id: https://gcc.gnu.org/g:df99e9e42094dee0833ac38f53e7fae09b4d133c commit r13-3402-gdf99e9e42094dee0833ac38f53e7fae09b4d133c Author: Richard Sandiford Date: Thu Oct 20 10:37:35 2022 +0100 aarch64: Commonise some folding code Add an aarch64_sve::gimple_folder helper for folding calls to integer constants. SME will make more use of this. 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. Diff: --- 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);