public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Making GNU GCC choose_multiplier in expmed.c significantly faster
@ 2018-07-11  7:26 colinb2 .
  0 siblings, 0 replies; 4+ messages in thread
From: colinb2 . @ 2018-07-11  7:26 UTC (permalink / raw)
  To: gcc

Clarification: this and my first post assume familiarity with choose_multiplier.

lgup=ceiling(log2(divisor))

Currently choose_multiplier initializes mlow, mhigh at post_shift=lgup;
initially 2^n<=mlow<mhigh so we must use "wide int" in the reduction iteration,
which is relatively slow because using "wide int" or a similar extended integer
type seems slow compared to using fixed width integer types.

But choose_multiplier_v2 initializes at post_shift=lgup-1, so mlow<=mhigh<2^n
and we can now avoid "wide int" in the reduction iteration. We can also
calculate mhigh from mlow without using "wide int", so we can limit using
"wide int" to calculating the initial value of mlow. Depending on the results
of benchmarking, it may even be that using choose_multiplier_v4 which completely
avoids "wide int" is faster than choose_multiplier_v2.

If for the initial values of mlow, mhigh we have mlow<mhigh then we can try
reducing mhigh. But if mlow>=mhigh then we need post_shift=lgup and we need
to use an extra bit for the multiplier, signified by returning 1 instead of 0.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-07-19 21:58 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CAMfC4qj_rfkcLnOYNDdnAU2RAqFmrPhHH+1g4mCW=4wgcHNwDg@mail.gmail.com>
2018-07-10 11:09 ` Making GNU GCC choose_multiplier in expmed.c significantly faster colinb2 .
2018-07-19 20:19   ` Jeff Law
2018-07-19 22:40     ` colinb2 .
2018-07-11  7:26 colinb2 .

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