From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 101115 invoked by alias); 25 Feb 2020 09:46:25 -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 100193 invoked by uid 89); 25 Feb 2020 09:46:24 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-20.9 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,MIME_CHARSET_FARAWAY,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.1 spammy=9, classification 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; Tue, 25 Feb 2020 09:46:14 +0000 Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 01P9iqpO012126 for ; Tue, 25 Feb 2020 04:46:13 -0500 Received: from e06smtp04.uk.ibm.com (e06smtp04.uk.ibm.com [195.75.94.100]) by mx0a-001b2d01.pphosted.com with ESMTP id 2yax38p2af-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 25 Feb 2020 04:46:13 -0500 Received: from localhost by e06smtp04.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 25 Feb 2020 09:46:10 -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) Tue, 25 Feb 2020 09:46:08 -0000 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 01P9k7BZ46858304 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 25 Feb 2020 09:46:07 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id ADEE9A4051; Tue, 25 Feb 2020 09:46:07 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2A640A4053; Tue, 25 Feb 2020 09:46:05 +0000 (GMT) Received: from KewenLins-MacBook-Pro.local (unknown [9.200.55.185]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 25 Feb 2020 09:46:04 +0000 (GMT) Subject: Re: [PATCH 2/4 GCC11] Add target hook stride_dform_valid_p To: Segher Boessenkool , GCC Patches , richard.sandiford@arm.com References: <20200120131451.GX3191@gate.crashing.org> Cc: Bill Schmidt , "bin.cheng" , Richard Guenther From: "Kewen.Lin" Date: Tue, 25 Feb 2020 09:46: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: <20200120131451.GX3191@gate.crashing.org> Content-Type: multipart/mixed; boundary="------------ED7EA644C5330F1578E4ACFF" x-cbid: 20022509-0016-0000-0000-000002EA0E18 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 20022509-0017-0000-0000-0000334D38DF Message-Id: <555ba68c-140c-a263-86b6-c5ccf32d4752@linux.ibm.com> X-IsSubscribed: yes X-SW-Source: 2020-02/txt/msg01372.txt.bz2 This is a multi-part message in MIME format. --------------ED7EA644C5330F1578E4ACFF Content-Type: text/plain; charset=gbk Content-Transfer-Encoding: 8bit Content-length: 1975 on 2020/1/20 ÏÂÎç9:14, Segher Boessenkool wrote: > Hi! > > On Mon, Jan 20, 2020 at 10:42:12AM +0000, Richard Sandiford wrote: >> "Kewen.Lin" writes: >>> 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. >> >> It looks like we should able to derive this information from the normal >> legitimate_address_p hook. > > Yes, probably. > >> Also, "D-form" vs. "X-form" is AFAIK a PowerPC-specific classification. >> It would be good to use a more generic term in target-independent code. > > Yeah. X-form is [reg+reg] addressing; D-form is [reg+imm] addressing. > We can do simple [reg] addressing in either form as well. Whether D-form > can be used for some access depends on many factors (ISA version, mode of > the datum, alignment, and how big the offset is of course). But the usual > legitimate_address_p hook should do fine. The ivopts code already has an > addr_offset_valid_p function, maybe that could be adjusted for this? > > > Segher > Hi Segher and Richard S., Sorry for late response. Thanks for your comments on legitimate_address_p hook and function addr_offset_valid_p. I updated the IVOPTs part with addr_offset_valid_p, although rs6000_legitimate_offset_address_p doesn't check strictly all the time (like worst_case is false), it works well with SPEC2017. Based on it, the hook is simplified as attached patch. BR, Kewen ----------- gcc/ChangeLog 2020-02-25 Kewen Lin * config/rs6000/rs6000.c (TARGET_CONSIDER_REG_OFFSET_FOR_UNROLL_P): New macro. * doc/tm.texi: Regenerate. * doc/tm.texi.in (TARGET_CONSIDER_REG_OFFSET_FOR_UNROLL_P): New hook. * target.def (consider_reg_offset_for_unroll_p): New hook. --------------ED7EA644C5330F1578E4ACFF Content-Type: text/plain; charset=UTF-8; x-mac-type="0"; x-mac-creator="0"; name="hook_v2.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="hook_v2.diff" Content-length: 3252 diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index 4c1c0e9..0eb13df 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -1652,6 +1652,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_CONSIDER_REG_OFFSET_FOR_UNROLL_P +#define TARGET_CONSIDER_REG_OFFSET_FOR_UNROLL_P true + #undef TARGET_HAVE_COUNT_REG_DECR_P #define TARGET_HAVE_COUNT_REG_DECR_P true diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi index 19985ad..fc21a3b 100644 --- a/gcc/doc/tm.texi +++ b/gcc/doc/tm.texi @@ -11680,6 +11680,18 @@ function version at run-time for a given set of function versions. body must be generated. @end deftypefn +@deftypevr {Target Hook} bool TARGET_CONSIDER_REG_OFFSET_FOR_UNROLL_P +When RTL unrolling performs on a loop, the duplicated loop iterations +have appropriate IV step update expressions. But if an IV is derived from +address object, it is profitable to fill its required offset updates into +appropriate memory access expressions if target memory accessing supports +the register offset mode and the resulted offset is in the valid range. +Return true if target supports register offset memory accessing mode and +wants IVOPTs or other passes to consider this information for better code +for unrolling. It needs to invoke unroll factor estimation in middle-end. +The default version of this hook returns false. +@end deftypevr + @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 1a16150..45377d3 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_CONSIDER_REG_OFFSET_FOR_UNROLL_P + @hook TARGET_PREDICT_DOLOOP_P @hook TARGET_HAVE_COUNT_REG_DECR_P diff --git a/gcc/target.def b/gcc/target.def index b5e82ff..a966d4f 100644 --- a/gcc/target.def +++ b/gcc/target.def @@ -4299,7 +4299,20 @@ 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) - + +DEFHOOKPOD +(consider_reg_offset_for_unroll_p, + "When RTL unrolling performs on a loop, the duplicated loop iterations\n\ +have appropriate IV step update expressions. But if an IV is derived from\n\ +address object, it is profitable to fill its required offset updates into\n\ +appropriate memory access expressions if target memory accessing supports\n\ +the register offset mode and the resulted offset is in the valid range.\n\ +Return true if target supports register offset memory accessing mode and\n\ +wants IVOPTs or other passes to consider this information for better code\n\ +for unrolling. It needs to invoke unroll factor estimation in middle-end.\n\ +The default version of this hook returns false.", + bool, false) + DEFHOOK (predict_doloop_p, "Return true if we can predict it is possible to use a low-overhead loop\n\ --------------ED7EA644C5330F1578E4ACFF--