🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.arch
Article #956

Re: Pentium 4

#956
From: Terje Mathisen
Date: Wed, 25 Nov 2026 21:07
69 lines
4887 bytes
Anton Ertl wrote:
> Terje Mathisen <terje.mathisen@tmsw.no> writes:
>> Anton Ertl wrote:
>>> Terje Mathisen <terje.mathisen@tmsw.no> writes:
>>>> Also, every switch between a sequence of inner core double-speed opcodes
>>>> and anything else caused a significant bubble.
>>>
>>> This is the first time I read about that.  And I have not seen it in
>>> my own measurements, but then, maybe I did not measure the right
>>> things.  Can you elaborate: E.g., give a sequence, and explain how big
>>> the bubble for that sequence is.
>>
>> I don't remember exactly, but believe it was on the order of 1-3
>> (external) clock cycles either way. Even at the lower limit, this meant
>> losing 4 double-clocked ops in overhead to execute a single slow opcode
>> like SHR.
> 
> AFAIK SHR was not just slow because it was not executed in the
> double-clocked ALU, but because it was executed in the mmxsh subunit
> according to Agner Fog's instruction tables.  His tables list latency
> 4+1 for shifts by immediate values and 6+0 for shifts by cl; the +1 or
> +0 happens if the execution unit of the next instruction is different
> from the current one.
> 
>  From what I read, shift and multiply shipped the operands over to
> functional units elsewhere (mmxsh in this case), losing a cycles or so
> each time a clock domain is crossed.  So let's see how fast the MMX
> shifts are: An instruction like PSRLD with a mmx register operand and
> an immediate operand costs 2+1 cycles.  So apparently shipping the GPR
> value over to the MMX shift unit costs 1 cycle there and 1 cycle back.
> For PSRLD xmm, xmm the cost is also 2+1; apparently SHR reg, CL has to
> do something extra.
> 
>> All the fast opcodes did half the register (16 bits) in each half-cycle,
>> so any instruction like shift right which needed access to the high bits
>> before it could start had to wait for that before the full-size result
>> could be sent out of the inner core, then do the intended instruction,
>> then move the result back into the inner core.
> 
> The most common instructions that are not in the double-speed ALU are
> loads, and for MOV r32,m Agner Fog lists 2+0 cycles of latency.  For
> an ALU instruction like ADD r,r Agner Fog lists 0.5 + 0.5..1 cycles of
> latency.
> 
> So for sequences of n repetitions of ADD r,r; MOV r,(r) the total
> latency is 3*n cycles.
> 
> And for sequences of n repetitions of ADD r,r; ADD r,r; MOV r,(r) the
> total latency of n*4 cycles.  Neither is worse than if there was no
> double-clocked ALU.
> 
> Looking up Prescott (later Pentium 4s without double-clocked ALU and
> partially with AMD64 support) numbers, Agner Fog lists 1+0 cycles
> latency for SHR r32,imm and 2+0 for SHR r32,CL, and alu1 as the unit,
> so the integer ALU now can shift.  ADD r,r has a latency of 1+0, and
> MOV r32,m has a latency of 2+0.  So for Prescott these latencies are
> quite ok.  What is strange is that the LEA latencies are listed as 2.5
> and 3.5.

Did I make a typo, or just didn't remember?

You are correct, it was both MUL and LEA which got much slower at the 
same time, taking away most ways to calculate addresses quickly.

Terje

-- 
- <Terje.Mathisen at tmsw.no>
"almost all programming can be viewed as an exercise in caching"
Technical Details
Message-ID: <11e7imc$4cdh$1@dont-email.me>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.hispagatos.org!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
References: <6aff95fd.2756312@news.eternal-september.org> <6b02f61c.2940750@news.eternal-september.org> <11dvql5$1cfvl$1@dont-email.me> <6b038fcc.42284937@news.eternal-september.org> <1795459538-5857@newsgrouper.org> <11e6gul$3mjp5$1@dont-email.me> <2026Nov25.135403@mips.complang.tuwien.ac.at> <11e6tbb$3rh80$1@dont-email.me> <2026Nov25.174522@mips.complang.tuwien.ac.at>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.hispagatos.org!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
From: Terje Mathisen <terje.mathisen@tmsw.no>
Newsgroups: comp.arch
Subject: Re: Pentium 4
Date: Wed, 25 Nov 2026 22:07:26 +0100
Organization: A noiseless patient Spider
Lines: 69
Message-ID: <11e7imc$4cdh$1@dont-email.me>
References: <6aff95fd.2756312@news.eternal-september.org>
 <6b02f61c.2940750@news.eternal-september.org> <11dvql5$1cfvl$1@dont-email.me>
 <6b038fcc.42284937@news.eternal-september.org>
 <1795459538-5857@newsgrouper.org> <11e6gul$3mjp5$1@dont-email.me>
 <2026Nov25.135403@mips.complang.tuwien.ac.at> <11e6tbb$3rh80$1@dont-email.me>
 <2026Nov25.174522@mips.complang.tuwien.ac.at>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 25 Nov 2026 21:07:25 +0000 (UTC)
Injection-Info: dont-email.me;
	logging-data="143793"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX190Q59y6fLRs+EMkIw6Ne9A+HXVZAOFDSkUYcfo/FeSYw=="; posting-host="771c882955cebfcc16025ed8ad627420"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:140.0) Gecko/20100101
 Firefox/140.0 SeaMonkey/2.53.24
Cancel-Lock: sha1:eM53re/lhALlaKUz009FtXbfyYk= sha256:oVeIOyQwbcTOgs2vPXnxiIQJKJNd0Cj+lHdqrLYW/Wc=
	sha1:ENeRXzjtK0ReG9cGuAKbH4kClq8= sha256:r63dFLha9x9Ueei8Kz2uGXQHicVupNsnbnNb+gK8Ayo=
In-Reply-To: <2026Nov25.174522@mips.complang.tuwien.ac.at>