public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Kewen.Lin" <linkw@linux.ibm.com>
To: Segher Boessenkool <segher@kernel.crashing.org>,
	       GCC Patches <gcc-patches@gcc.gnu.org>,
	richard.sandiford@arm.com
Cc: Bill Schmidt <wschmidt@linux.ibm.com>,
	       "bin.cheng" <bin.cheng@linux.alibaba.com>,
	       Richard Guenther <rguenther@suse.de>
Subject: Re: [PATCH 2/4 GCC11] Add target hook stride_dform_valid_p
Date: Tue, 25 Feb 2020 09:46:00 -0000	[thread overview]
Message-ID: <555ba68c-140c-a263-86b6-c5ccf32d4752@linux.ibm.com> (raw)
In-Reply-To: <20200120131451.GX3191@gate.crashing.org>

[-- Attachment #1: Type: text/plain, Size: 1979 bytes --]

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" <linkw@linux.ibm.com> writes:
>>> gcc/ChangeLog
>>>
>>> 2020-01-16  Kewen Lin  <linkw@gcc.gnu.org>
>>>
>>> 	* 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  <linkw@gcc.gnu.org>

	* 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.

[-- Attachment #2: hook_v2.diff --]
[-- Type: text/plain, Size: 3252 bytes --]

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\

  reply	other threads:[~2020-02-25  9:46 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-16  9:41 [PATCH 0/4 GCC11] IVOPTs consider step cost for different forms when unrolling Kewen.Lin
2020-01-16  9:43 ` [PATCH 1/4 GCC11] Add middle-end unroll factor estimation Kewen.Lin
2020-01-20 13:12   ` Segher Boessenkool
2020-02-10  6:20     ` [PATCH 1/4 v2 " Kewen.Lin
2020-02-10 23:34       ` Segher Boessenkool
2020-02-11  6:51         ` [PATCH 1/4 v3 " Kewen.Lin
2020-02-11  7:00           ` Segher Boessenkool
2020-02-11  2:15       ` [PATCH 1/4 v2 " Jiufu Guo
2020-02-11  3:04         ` Kewen.Lin
2020-01-16 10:02 ` [PATCH 2/4 GCC11] Add target hook stride_dform_valid_p Kewen.Lin
2020-01-20 10:53   ` Richard Sandiford
2020-01-20 11:47     ` Richard Biener
2020-01-20 13:20     ` Segher Boessenkool
2020-02-25  9:46       ` Kewen.Lin [this message]
2020-03-02 11:09         ` Richard Sandiford
2020-03-03 12:26           ` Kewen.Lin
2020-05-13  5:50             ` Kewen.Lin
2020-05-28  2:17               ` Ping^1 [PATCH 2/4 V3] " Kewen.Lin
2020-05-28 10:54                 ` Richard Sandiford
2020-01-16 10:06 ` [PATCH 3/4 GCC11] IVOPTs Consider cost_step on different forms during unrolling Kewen.Lin
2020-02-25  9:48   ` [PATCH 3/4 V2 " Kewen.Lin
2020-05-13  5:42     ` [PATCH 3/4 V3 " Kewen.Lin
2020-01-16 10:12 ` [PATCH 4/4 GCC11] rs6000: P9 D-form test cases Kewen.Lin
2020-01-20 13:37   ` Segher Boessenkool
2020-02-10  6:25     ` [PATCH 4/4 v2 " Kewen.Lin
2020-02-10 23:51       ` Segher Boessenkool
2020-01-20 13:03 ` [PATCH 0/4 GCC11] IVOPTs consider step cost for different forms when unrolling Segher Boessenkool
2020-02-10  6:17   ` Kewen.Lin
2020-02-10 21:29     ` Segher Boessenkool
2020-02-11  2:56       ` Kewen.Lin
2020-02-11  7:34       ` Richard Biener
2020-02-11  7:49         ` Segher Boessenkool
2020-02-11  8:01           ` Richard Biener
2020-02-11 12:46             ` Roman Zhuykov
2020-02-11 13:58               ` Richard Biener
2020-02-11 18:00                 ` Segher Boessenkool
2020-02-12  8:07                   ` Richard Biener
2020-02-12 21:53                     ` Segher Boessenkool
2020-02-11 18:12               ` Segher Boessenkool
2020-02-12  8:13                 ` Richard Biener
2020-02-12 10:02                   ` Segher Boessenkool
2020-02-12 10:53                     ` Richard Biener
2020-02-12 22:05                       ` Segher Boessenkool
2020-02-13  7:48                         ` Richard Biener
2020-02-13  9:02                           ` Segher Boessenkool

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=555ba68c-140c-a263-86b6-c5ccf32d4752@linux.ibm.com \
    --to=linkw@linux.ibm.com \
    --cc=bin.cheng@linux.alibaba.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=rguenther@suse.de \
    --cc=richard.sandiford@arm.com \
    --cc=segher@kernel.crashing.org \
    --cc=wschmidt@linux.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).