Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| Message-ID | <4DD3C8CA.70909@SPAM.comp-arch.net> (permalink) |
|---|---|
| Date | 2011-05-18 06:25 -0700 |
| From | "Andy \"Krazy\" Glew" <andy@SPAM.comp-arch.net> |
| Organization | comp-arch.net |
| Newsgroups | comp.arch |
| Subject | Re: Why is complex lea slow? |
| References | <9ceb0829-013e-4ee4-8ab3-9378ae59fe37@glegroupsg2000goo.googlegroups.com> <eo9ca8-fmg.ln1@ntp6.tmsw.no> |
On 5/18/2011 12:40 AM, Terje Mathisen wrote:
> Paul A. Clayton wrote:
>> In the context of LEA, the shifts are always constant and
>> I was under the impression that variable shifts are
>> generally less common.
>
> Chicken & Egg?
>
> Variable shifts have tended to be slower on many (micro-)architectures,
> making programmers (and compiler writers) less likely to use them.
>
> I.e. I have written lots of code, particularly anything that has to do
> with bit banging, where fast variable shifts would have allowed me to
> simplify the code and/or employ bit-level packing instead of using a
> byte per flag.
>
> Terje
The x86 OOO/P6 family slowness for variable shifts is largely due to the
fact that a variable shift by zero was defined be a NOP. On a 2-input
OOO machine, this necessitated a third input for the old flags, and a
second uop:
tmp := concat( value_to_be_shifted, old_flags )
dest,new_flags := shift( tmp, shift_count )
or (with lower latency for the shift, and a widget uop to handle to flag
selection)
dest,tmp_flags := shift( value_to_be_shifted, shift_count )
final_flags := select_shift_flags( tmp_flags, old_flags)
If the instruction had been defined without this 0-NOP flag business,
e.g. if you set a flag combination on zero rather than inheriting one,
it would have been faster.
Now that 3-input datapaths are common for multiply-add, this could be
undone. Perhaps it has already been?
---
Apart from this, why are dynamic shifts slow? What machines make them
slow?
A dynamic shift is always going to be more expensive than a shift by 1
or 2 bits. At least, you can probably build 4 shift by 1s, but only 1
dynamic full width shifter, on a typical datapath. But not necessarily
more expensive than a shift by a large constant, unless tyhe sort of
optimization Paul was talking about is done. Which has not been the
case in my experieence.
But, you are right: dynamic shifts are often penalized.
E.g. on Gould we did not have them: we had to resort to the moral
equivalent of self-modifying code, generating the shift by constant in a
register and then using the execute register instruction.
This sounds like an essay for the comp-arch.net wiki.
What machines make dynamic shifts slower than, say, a shift by 29?
Why?
Is it fundamental, or is it an accident of the instruction set, as it
was for x86 and Gould?
What would an instruction set definition of dynamic shift look like that
did NOT causse such implementation artifacts look like?
Back to comp.arch | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: Why is complex lea slow? "Paul A. Clayton" <paaronclayton@gmail.com> - 2011-05-17 12:58 -0700
Re: Why is complex lea slow? Terje Mathisen <"terje.mathisen at tmsw.no"> - 2011-05-18 09:40 +0200
Re: Why is complex lea slow? "Andy \"Krazy\" Glew" <andy@SPAM.comp-arch.net> - 2011-05-18 06:25 -0700
Re: Why is complex lea slow? "Andy \"Krazy\" Glew" <andy@SPAM.comp-arch.net> - 2011-05-18 06:39 -0700
Re: Why is complex lea slow? Terje Mathisen <"terje.mathisen at tmsw.no"> - 2011-05-18 20:49 +0200
Re: Why is complex lea slow? Andrew Reilly <areilly---@bigpond.net.au> - 2011-05-19 00:11 +0000
Re: Why is complex lea slow? MitchAlsup <MitchAlsup@aol.com> - 2011-05-24 13:44 -0700
Re: Why is complex lea slow? Terje Mathisen <"terje.mathisen at tmsw.no"> - 2011-05-25 08:43 +0200
Re: Why is complex lea slow? MitchAlsup <MitchAlsup@aol.com> - 2011-05-25 08:31 -0700
Re: Why is complex lea slow? timcaffrey@aol.com (Tim McCaffrey) - 2011-05-25 14:53 +0000
Re: Why is complex lea slow? MitchAlsup <MitchAlsup@aol.com> - 2011-05-25 08:31 -0700
Re: Why is complex lea slow? timcaffrey@aol.com (Tim McCaffrey) - 2011-05-26 19:45 +0000
Re: Why is complex lea slow? kym@kymhorsell.com - 2011-05-26 20:01 +0000
Re: Why is complex lea slow? nmm1@cam.ac.uk - 2011-05-26 20:29 +0100
Re: Why is complex lea slow? kym@kymhorsell.com - 2011-05-26 20:14 +0000
Re: Why is complex lea slow? nmm1@cam.ac.uk - 2011-05-26 21:04 +0100
Re: Why is complex lea slow? kym@kymhorsell.com - 2011-05-26 20:55 +0000
Re: Why is complex lea slow? kym@kymhorsell.com - 2011-05-26 20:57 +0000
Re: Why is complex lea slow? nmm1@cam.ac.uk - 2011-05-26 21:30 +0100
Re: Why is complex lea slow? Tom Gardner <spamjunk@blueyonder.co.uk> - 2011-05-26 22:57 +0100
Re: Why is complex lea slow? Terje Mathisen <"terje.mathisen at tmsw.no"> - 2011-05-27 07:42 +0200
Re: Why is complex lea slow? kym@kymhorsell.com - 2011-05-27 06:11 +0000
Re: Why is complex lea slow? Tom Gardner <spamjunk@blueyonder.co.uk> - 2011-05-27 07:18 +0100
Re: Why is complex lea slow? kym@kymhorsell.com - 2011-05-27 06:33 +0000
Re: Why is complex lea slow? Michael S <already5chosen@yahoo.com> - 2011-05-27 03:24 -0700
Re: Why is complex lea slow? Tom Gardner <spamjunk@blueyonder.co.uk> - 2011-05-27 22:24 +0100
Re: Why is complex lea slow? Terje Mathisen <"terje.mathisen at tmsw.no"> - 2011-05-28 13:51 +0200
Re: Why is complex lea slow? Quadibloc <jsavard@ecn.ab.ca> - 2011-05-27 17:42 -0700
Re: Why is complex lea slow? Quadibloc <jsavard@ecn.ab.ca> - 2011-05-27 17:40 -0700
Re: Why is complex lea slow? Terje Mathisen <"terje.mathisen at tmsw.no"> - 2011-05-27 08:55 +0200
Re: Why is complex lea slow? kym@kymhorsell.com - 2011-05-27 07:42 +0000
Re: Why is complex lea slow? Tom Gardner <spamjunk@blueyonder.co.uk> - 2011-05-27 09:24 +0100
Re: Why is complex lea slow? nmm1@cam.ac.uk - 2011-05-27 08:55 +0100
Re: Why is complex lea slow? Tom Gardner <spamjunk@blueyonder.co.uk> - 2011-05-27 10:20 +0100
Re: Why is complex lea slow? kym@kymhorsell.com - 2011-05-27 08:53 +0000
Re: Why is complex lea slow? Tom Gardner <spamjunk@blueyonder.co.uk> - 2011-05-27 10:23 +0100
Re: Why is complex lea slow? kenney@cix.compulink.co.uk - 2011-05-27 23:47 -0500
Re: Why is complex lea slow? Quadibloc <jsavard@ecn.ab.ca> - 2011-05-27 17:44 -0700
Re: Why is complex lea slow? Bill Findlay <yaldnif.w@blueyonder.co.uk> - 2011-05-28 02:12 +0100
Re: Why is complex lea slow? kym@kymhorsell.com - 2011-05-28 02:57 +0000
Re: Why is complex lea slow? Tom Gardner <spamjunk@blueyonder.co.uk> - 2011-05-28 09:27 +0100
Algol hardware representations, was: Why is complex lea slow? Bill Findlay <yaldnif.w@blueyonder.co.uk> - 2011-05-28 15:26 +0100
Re: Why is complex lea slow? Quadibloc <jsavard@ecn.ab.ca> - 2011-05-28 08:57 -0700
Re: Why is complex lea slow? Chris Gray <cg@GraySage.com> - 2011-05-27 14:14 -0600
Re: Why is complex lea slow? timcaffrey@aol.com (Tim McCaffrey) - 2011-05-26 23:26 +0000
Re: Why is complex lea slow? Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2011-05-26 21:41 -0600
Re: Why is complex lea slow? Terje Mathisen <"terje.mathisen at tmsw.no"> - 2011-05-27 07:37 +0200
Re: Why is complex lea slow? kym@kymhorsell.com - 2011-05-27 06:16 +0000
Re: Why is complex lea slow? Quadibloc <jsavard@ecn.ab.ca> - 2011-05-27 17:52 -0700
Re: Why is complex lea slow? Piotr Wyderski <peter.pan@neverland.mil> - 2011-05-19 17:13 +0200
csiph-web