public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Kewen.Lin" <linkw@linux.ibm.com>
To: "Bin.Cheng" <amker.cheng@gmail.com>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>,
	"bin.cheng" <bin.cheng@linux.alibaba.com>,
	Richard Guenther <rguenther@suse.de>,
	Bill Schmidt <wschmidt@linux.ibm.com>,
	Segher Boessenkool <segher@kernel.crashing.org>,
	Richard Sandiford <richard.sandiford@arm.com>,
	Jiufu Guo <guojiufu@linux.ibm.com>
Subject: Re: [PATCH 3/4 v3] ivopts: Consider cost_step on different forms during unrolling
Date: Wed, 2 Sep 2020 11:50:19 +0800	[thread overview]
Message-ID: <311f2a04-70a1-a871-b111-646a3cef8e82@linux.ibm.com> (raw)
In-Reply-To: <CAHFci2-dg0o9jweJdQCM36NiOQTd7btHDZCjL5PDXinyYhZdOg@mail.gmail.com>

Hi Bin,

>> 2) This case makes me think we should exclude ainc candidates in function
>> mark_reg_offset_candidates.  The justification is that: ainc candidate
>> handles step update itself and when we calculate the cost for it against
>> its ainc_use, the cost_step has been reduced. When unrolling happens,
>> the ainc computations are replicated and it doesn't save step updates
>> like normal reg_offset_p candidates.
> Though auto-inc candidate embeds stepping operation into memory
> access, we might want to avoid it in case of unroll if there are many
> sequences of memory accesses, and if the unroll factor is big.  The
> rationale is embedded stepping is a u-arch operation and does have its
> cost.
> 

Thanks for the comments!  Agree!  Excluding them from reg_offset_p
candidates here is consistent with this expectation, it makes us
consider the unroll factor effect when checking the corresponding
step cost and the embedded stepping cost (in group/candidate cost,
minus step cost and use the cost from the address_cost hook).

>>
>> I've updated the patch to punt ainc_use candidates as below:
>>
>>> +         /* Skip AINC candidate since it contains address update itself,
>>> +            the replicated AINC computations when unrolling still have
>>> +            updates, unlike reg_offset_p candidates can save step updates
>>> +            when unrolling.  */
>>> +         if (cand->ainc_use)
>>> +           continue;
>>> +
>>
>> For this new attached patch, it's bootstrapped and regress-tested without
>> explicit unrolling, while the only one failure has been identified as
>> rs6000 specific address_cost issue in bootstrapping and regression testing
>> with explicit unrolling.
>>
>> By the way, with above simple hack of address_cost, I also did one
>> bootstrapping and regression testing with explicit unrolling, the above
>> sms-4.c did pass as I expected but had two failures instead:
>>
>>   PASS->FAIL: gcc.dg/sms-compare-debug-1.c (test for excess errors)
>>   PASS->FAIL: gcc.dg/tree-ssa/ivopts-lt.c scan-tree-dump-times ivopts "PHI" 2
>>
>> By further investigation, the 2nd one is expected due to the adddress_cost hook
>> hack, while the 1st one one exposed -fcompare-debug issue in sms.  The RTL
>> sequence starts to off from sms, just some NOTE_INSN_DELETED positions change.
>> I believe it's just exposed by this combination unluckily/luckily ;-) I will
>> send a patch separately for it once I got time to look into it, but it should
>> be unrelated to this patch series for sure.
> This is the kind of situation I intended to avoid before.  IMHO, this
> isn't a neat change (it can't be given we are predicting the future
> transformation in compilation pipeline), accumulation of such changes
> could make IVOPTs break in one way or another.  So as long as you make
> sure it doesn't have functional impact in case of no-rtl_unroll, I am
> fine.

Yeah, I admit it's not neat, but the proposals in the previous discussions
without predicting unroll factor can not work well for all scenarios with
different unroll factors, they could over-blame some kind of candidates.
For the case of no-rtl_unroll, unroll factor estimation should set
loop->estimated_unroll to zero, all these changes won't take effect. The
estimation function follows the same logics as that of RTL unroll factor
calculation, I did test with explicit unrolling disablement before, it
worked expectedly.

BR,
Kewen

  reply	other threads:[~2020-09-02  3:50 UTC|newest]

Thread overview: 64+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-28 12:17 [PATCH 0/4] IVOPTs consider step cost for different forms when unrolling Kewen.Lin
2020-05-28 12:19 ` [PATCH 1/4] unroll: Add middle-end unroll factor estimation Kewen.Lin
2020-08-31  5:49   ` PING " Kewen.Lin
2020-09-15  7:44     ` PING^2 " Kewen.Lin
2020-10-13  7:06       ` PING^3 " Kewen.Lin
2020-11-02  9:13         ` PING^4 " Kewen.Lin
2020-11-19  5:50           ` PING^5 " Kewen.Lin
2020-12-17  2:58             ` PING^6 " Kewen.Lin
2021-01-14  2:36               ` PING^7 " Kewen.Lin
2021-01-21 21:45   ` Segher Boessenkool
2021-01-22 12:50     ` Richard Sandiford
2021-01-22 13:47     ` Richard Biener
2021-01-22 21:37       ` Segher Boessenkool
2021-01-25  7:56         ` Richard Biener
2021-01-25 17:59           ` Richard Sandiford
2021-01-25 20:37             ` Segher Boessenkool
2021-01-26  8:53               ` Kewen.Lin
2021-01-26 17:31                 ` Segher Boessenkool
2021-01-26  8:43             ` Kewen.Lin
2021-01-26 10:47             ` Richard Biener
2021-01-26 17:54               ` Segher Boessenkool
2021-01-26  8:36           ` Kewen.Lin
2021-01-26 10:53             ` Richard Biener
2021-01-27  9:43               ` Kewen.Lin
2021-03-01  2:45                 ` Kewen.Lin
2020-05-28 12:23 ` [PATCH 2/4] param: Introduce one param to control ivopts reg-offset consideration Kewen.Lin
2020-05-28 12:24 ` [PATCH 3/4] ivopts: Consider cost_step on different forms during unrolling Kewen.Lin
2020-06-01 17:59   ` Richard Sandiford
2020-06-02  3:39     ` Kewen.Lin
2020-06-02  7:14       ` Richard Sandiford
2020-06-03  3:18         ` Kewen.Lin
2020-08-08  8:01   ` Bin.Cheng
2020-08-10  4:27     ` Kewen.Lin
2020-08-10 12:38       ` Bin.Cheng
2020-08-10 14:41         ` Kewen.Lin
2020-08-16  3:59           ` Bin.Cheng
2020-08-18  9:02             ` [PATCH 3/4 v2] " Kewen.Lin
2020-08-22  5:11               ` Bin.Cheng
2020-08-25 12:46                 ` [PATCH 3/4 v3] " Kewen.Lin
2020-08-31 19:41                   ` Segher Boessenkool
2020-09-02  3:16                     ` Kewen.Lin
2020-09-02 10:25                       ` Segher Boessenkool
2020-09-03  2:24                         ` Kewen.Lin
2020-09-03 22:37                           ` Segher Boessenkool
2020-09-04  8:27                             ` Bin.Cheng
2020-09-04 13:53                               ` Segher Boessenkool
2020-09-04  8:47                             ` Kewen.Lin
2020-09-04 14:16                               ` Segher Boessenkool
2020-09-04 15:47                                 ` Kewen.Lin
2020-09-17 23:12                             ` Jeff Law
2020-09-17 23:46                               ` Segher Boessenkool
2020-09-01 11:19                   ` Bin.Cheng
2020-09-02  3:50                     ` Kewen.Lin [this message]
2020-09-02  3:55                       ` Bin.Cheng
2020-09-02  4:51                         ` Kewen.Lin
2020-09-06  2:47                     ` Hans-Peter Nilsson
2020-09-15  7:41                       ` Kewen.Lin
2020-06-02 11:38 ` [PATCH 0/4] IVOPTs consider step cost for different forms when unrolling Richard Biener
2020-06-03  3:46   ` Kewen.Lin
2020-06-03  7:07     ` Richard Biener
2020-06-03  7:58       ` Kewen.Lin
2020-06-03  9:27         ` Richard Biener
2020-06-03 10:47           ` Kewen.Lin
2020-06-03 11:08             ` Richard Sandiford

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=311f2a04-70a1-a871-b111-646a3cef8e82@linux.ibm.com \
    --to=linkw@linux.ibm.com \
    --cc=amker.cheng@gmail.com \
    --cc=bin.cheng@linux.alibaba.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=guojiufu@linux.ibm.com \
    --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).