From: Dale Johannesen <dalej@apple.com>
To: Richard Henderson <rth@redhat.com>
Cc: Dale Johannesen <dalej@apple.com>, gcc-patches@gcc.gnu.org
Subject: Re: Patch: fix SPEC regressions
Date: Tue, 29 Oct 2002 15:10:00 -0000 [thread overview]
Message-ID: <986ACCAA-EB93-11D6-B8DA-000393D76DAA@apple.com> (raw)
In-Reply-To: <20021029183821.GB3036@redhat.com>
On Tuesday, October 29, 2002, at 10:38 AM, Richard Henderson wrote:
> On Tue, Oct 29, 2002 at 09:40:32AM -0800, Dale Johannesen wrote:
>> Sure, I left it this way to make reading it easier. Not that's
>> it's easy anyway.
>
> Err, but why? Why are we computing it this way?
Ah, that's a different question. I deliberately didn't explain, in the
hope that somebody would derive it independently, thus giving us more
assurance we've finally gotten this right. However:
We have a loop running from 'initial' to 'final' with increment
'abs_inc',
and we're going to make 'unroll_number' copies of it. Typically the
number of iterations of the original loop will not be exactly divisible
by unroll_number, and in that case we'll need to add an extra iteration
of the unrolled loop which is only partially executed. As I said
already,
preconditioning is expected to (and does) increment 'initial'
appropriately
if any preiterations were done, so we don't have to worry about that.
Also, we assume that a runtime check for zero iterations was generated
elsewhere
if needed, so we don't have to do anything special for that.
Note that 'final' is the expected value of the index after the loop;
for the
common C form of loop for(i=0; i<final; i+=abs_inc) the loop body is
not to be
executed with i=='final', the max value is final-abs_inc. This form is
used
in examples.
The increment for the unrolled loop will obviously be
abs_inc*unroll_number,
which we define as t1. For a given value of 'initial', it should be
evident
that there are t1 different values of 'final' for which the number of
fully executed iterations are the same. For example, suppose abs_inc=3,
initial=3, unroll_number=4. Any value of 'final' between 13 and 24
inclusive
requires 1 full iteration. To round up the edge cases correctly we
need to adjust
final-initial by abs_inc-1; thus,
(final-initial+abs_inc-1)/t1
or ((13..24-3) + 2)/(3*4) in the example.
Of the t1 different values of 'final' for a given number of fully
executed
iterations, there are from 0..unroll_number-1 possible extra
iterations (of
the original loop) necessary (call this t2); we only care whether t2 is
0 or not.
Evidently abs_inc different values of 'final' correspond to each t2 (in
particular
to t2==0), and t2 is computed straightforwardly as
((final-initial+abs_inc-1)%t1)/abs_inc,
reducing the range first to 0..t1-1 then to 0..unroll_loops-1. We only
care
that t2!=0, which happens when
((final-initial+abs_inc-1)%t1) >= abs_inc
or for 15..24 in the example. That is, the bottom abs_inc values of
the t1 'final'
values do not require a second iteration, the rest do.
As you point out this simplifies to
(abs(final-initial) + abs_inc*unroll_number - 1) / t1
next prev parent reply other threads:[~2002-10-29 23:10 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-10-28 11:40 Dale Johannesen
2002-10-29 7:46 ` Richard Henderson
2002-10-29 9:40 ` Dale Johannesen
2002-10-29 10:38 ` Richard Henderson
2002-10-29 15:10 ` Dale Johannesen [this message]
2002-10-31 15:18 ` Richard Henderson
2002-10-31 15:22 ` Dale Johannesen
2002-10-31 17:41 ` Richard Henderson
2002-11-01 15:56 ` Patch: fix SPEC regressions (rewrite) Dale Johannesen
2002-11-03 15:32 ` Richard Henderson
2002-11-21 10:18 ` Patch: fix SPEC regressions Eric Botcazou
2002-11-21 13:52 ` Richard Henderson
2002-12-14 14:48 ` Eric Botcazou
2002-12-17 5:35 ` Eric Botcazou
2002-12-19 13:15 ` Richard Henderson
2002-12-19 13:40 ` Eric Botcazou
2002-12-19 13:20 ` Richard Henderson
2002-12-21 12:34 ` Eric Botcazou
2002-12-21 4:16 ` Eric Botcazou
2002-12-21 11:19 ` Richard Henderson
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=986ACCAA-EB93-11D6-B8DA-000393D76DAA@apple.com \
--to=dalej@apple.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=rth@redhat.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).