Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| Date | 2011-05-18 20:49 +0200 |
|---|---|
| From | Terje Mathisen <"terje.mathisen at tmsw.no"> |
| 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> <4DD3C8CA.70909@SPAM.comp-arch.net> |
| Message-ID | <avgda8-23i.ln1@ntp6.tmsw.no> (permalink) |
Andy "Krazy" Glew wrote:
> On 5/18/2011 12:40 AM, Terje Mathisen wrote:
>> 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:
[snip]
> 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.
Since the definition was (modulo bugs) however the 808x did it, a
microcoded variable shift where no shift == NOP probably made sense at
the time. :-(
> 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.
Having an execute instruction, like the IBM 360/370, makes
self-modifying code both simple and relatively clean.
I.e. it becomes very obvious where you are doing this stuff, and you can
leave your code segments read-only.
You could of course have done the same thing with computed branch addresses:
Either a completely unrolled version:
and cx,31 ; 0 to 31 shift count
mov bx, offset shift_end
sub bx,cx
sub bx,cx
sub bx,cx
jmp bx
shift_start:
rept 31
shr ax,1 ;; A 3-byte opcode
endm
shift_end:
or a binary set of fixed-size shifts:
test cl,16
jz skip16
shr ax,16
skip16:
test cl,8
jz skip8
shr ax,8
skip8:
...
etc.
test cl,1
jz skip1
shr ax,1
skip1:
Terje
--
- <Terje.Mathisen at tmsw.no>
"almost all programming can be viewed as an exercise in caching"
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