From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1006 invoked by alias); 16 Jan 2020 09:41:06 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 992 invoked by uid 89); 16 Jan 2020 09:41:05 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-20.7 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: mx0a-001b2d01.pphosted.com Received: from mx0a-001b2d01.pphosted.com (HELO mx0a-001b2d01.pphosted.com) (148.163.156.1) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 16 Jan 2020 09:40:55 +0000 Received: from pps.filterd (m0187473.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 00G9bZ8U034770 for ; Thu, 16 Jan 2020 04:40:53 -0500 Received: from e06smtp04.uk.ibm.com (e06smtp04.uk.ibm.com [195.75.94.100]) by mx0a-001b2d01.pphosted.com with ESMTP id 2xfaw28bv5-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 16 Jan 2020 04:40:53 -0500 Received: from localhost by e06smtp04.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 16 Jan 2020 09:40:50 -0000 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp04.uk.ibm.com (192.168.101.134) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Thu, 16 Jan 2020 09:40:48 -0000 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 00G9elaK48103428 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 16 Jan 2020 09:40:47 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AC09552067; Thu, 16 Jan 2020 09:40:47 +0000 (GMT) Received: from kewenlins-mbp.cn.ibm.com (unknown [9.200.147.222]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTP id 96A3E5204E; Thu, 16 Jan 2020 09:40:45 +0000 (GMT) Subject: [PATCH 2/4 GCC11] Add target hook stride_dform_valid_p From: "Kewen.Lin" To: GCC Patches Cc: Segher Boessenkool , Bill Schmidt , "bin.cheng" , Richard Guenther References: Date: Thu, 16 Jan 2020 10:02:00 -0000 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:68.0) Gecko/20100101 Thunderbird/68.2.2 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/mixed; boundary="------------FC847189A295AE70743BCD62" x-cbid: 20011609-0016-0000-0000-000002DDCD82 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 20011609-0017-0000-0000-000033406466 Message-Id: X-IsSubscribed: yes X-SW-Source: 2020-01/txt/msg00943.txt.bz2 This is a multi-part message in MIME format. --------------FC847189A295AE70743BCD62 Content-Type: text/plain; charset=gbk Content-Transfer-Encoding: 7bit Content-length: 310 gcc/ChangeLog 2020-01-16 Kewen Lin * config/rs6000/rs6000.c (TARGET_STRIDE_DFORM_VALID_P): New macro. (rs6000_stride_dform_valid_p): New function. * doc/tm.texi: Regenerate. * doc/tm.texi.in (TARGET_STRIDE_DFORM_VALID_P): New hook. * target.def (stride_dform_valid_p): New hook. --------------FC847189A295AE70743BCD62 Content-Type: text/plain; charset=UTF-8; x-mac-type="0"; x-mac-creator="0"; name="0002.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0002.patch" Content-length: 4308 gcc/config/rs6000/rs6000.c | 40 ++++++++++++++++++++++++++++++++++++++++ gcc/doc/tm.texi | 8 ++++++++ gcc/doc/tm.texi.in | 2 ++ gcc/target.def | 13 ++++++++++++- 4 files changed, 62 insertions(+), 1 deletion(-) diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index 0dabaa6..1e41fcf 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -1657,6 +1657,9 @@ static const struct attribute_spec rs6000_attribute_table[] = #undef TARGET_PREDICT_DOLOOP_P #define TARGET_PREDICT_DOLOOP_P rs6000_predict_doloop_p +#undef TARGET_STRIDE_DFORM_VALID_P +#define TARGET_STRIDE_DFORM_VALID_P rs6000_stride_dform_valid_p + #undef TARGET_HAVE_COUNT_REG_DECR_P #define TARGET_HAVE_COUNT_REG_DECR_P true @@ -26272,6 +26275,43 @@ rs6000_predict_doloop_p (struct loop *loop) return true; } +/* Return true if the memory access with mode MODE, signedness SIGNED_P and + store STORE_P with offset from 0 to (NUNROLL-1) * STRIDE are valid with + D-form instructions. */ + +static bool +rs6000_stride_dform_valid_p (machine_mode mode, signed HOST_WIDE_INT stride, + bool signed_p, bool store_p, unsigned nunroll) +{ + static const HOST_WIDE_INT max_bound = 0x7fff; + static const HOST_WIDE_INT min_bound = -0x8000; + + if (!IN_RANGE ((nunroll - 1) * stride, min_bound, max_bound)) + return false; + + /* Check DQ-form for vector mode or float128 mode. */ + if (VECTOR_MODE_P (mode) || FLOAT128_VECTOR_P (mode)) + { + if (mode_supports_dq_form (mode) && !(stride & 0xF)) + return true; + else + return false; + } + + /* Simply consider non VSX instructions. */ + if (mode == QImode || mode == HImode || mode == SFmode || mode == DFmode) + return true; + + /* lwz/stw is D-form, but lwa is DS-form. */ + if (mode == SImode && (!signed_p || store_p || !(stride & 0x03))) + return true; + + if (mode == DImode && !(stride & 0x03)) + return true; + + return false; +} + struct gcc_target targetm = TARGET_INITIALIZER; #include "gt-rs6000.h" diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi index 86ad278..0b8bc7c 100644 --- a/gcc/doc/tm.texi +++ b/gcc/doc/tm.texi @@ -11669,6 +11669,14 @@ function version at run-time for a given set of function versions. body must be generated. @end deftypefn +@deftypefn {Target Hook} bool TARGET_STRIDE_DFORM_VALID_P (machine_mode @var{mode}, signed HOST_WIDE_INT @var{stride}, bool @var{signed_p}, bool @var{store_p}, unsigned @var{nunroll}) +For a given memory access, check whether it is valid to put 0, @var{stride} +, 2 * @var{stride}, ... , (@var{nunroll} - 1) to the instruction D-form +displacement, with mode @var{mode}, signedness @var{signed_p} and store +@var{store_p}. Return true if valid. +The default version of this hook returns false. +@end deftypefn + @deftypefn {Target Hook} bool TARGET_PREDICT_DOLOOP_P (class loop *@var{loop}) Return true if we can predict it is possible to use a low-overhead loop for a particular loop. The parameter @var{loop} is a pointer to the loop. diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in index fd9769e..e90d020 100644 --- a/gcc/doc/tm.texi.in +++ b/gcc/doc/tm.texi.in @@ -7953,6 +7953,8 @@ to by @var{ce_info}. @hook TARGET_GENERATE_VERSION_DISPATCHER_BODY +@hook TARGET_STRIDE_DFORM_VALID_P + @hook TARGET_PREDICT_DOLOOP_P @hook TARGET_HAVE_COUNT_REG_DECR_P diff --git a/gcc/target.def b/gcc/target.def index f61c831..ee19a8d 100644 --- a/gcc/target.def +++ b/gcc/target.def @@ -4300,7 +4300,18 @@ DEFHOOK emits a @code{speculation_barrier} instruction if that is defined.", rtx, (machine_mode mode, rtx result, rtx val, rtx failval), default_speculation_safe_value) - + +DEFHOOK +(stride_dform_valid_p, + "For a given memory access, check whether it is valid to put 0, @var{stride}\n\ +, 2 * @var{stride}, ... , (@var{nunroll} - 1) to the instruction D-form\n\ +displacement, with mode @var{mode}, signedness @var{signed_p} and store\n\ +@var{store_p}. Return true if valid.\n\ +The default version of this hook returns false.", + bool, (machine_mode mode, signed HOST_WIDE_INT stride, bool signed_p, + bool store_p, unsigned nunroll), + NULL) + DEFHOOK (predict_doloop_p, "Return true if we can predict it is possible to use a low-overhead loop\n\ -- 2.7.4 --------------FC847189A295AE70743BCD62--