๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.arch
Article #122

Re: Performance of xchg reg,reg

#122
From: MitchAlsup
Date: Wed, 14 Oct 2026 22:35
38 lines
2701 bytes
anton@mips.complang.tuwien.ac.at (Anton Ertl) posted:

> /ERROR "unexpected byte sequence starting at index 607: '\xE2'" while decoding/:
> 
> Lawrence =?iso-8859-13?q?D=FFOliveiro?= <ldo@nz.invalid> writes:
> >On Tue, 13 Oct 2026 08:43:47 GMT, Anton Ertl wrote:
> >
> >> On Zen5, even a 5-register cycle can be profitably implemented with
> >> xchg when you have no spare register, a 4-register cycle even when
> >> you have a spare register. For Zen4 and Zen3 cyc4 (for mem) and cyc3
> >> (for reg) are borderline cases, and for shorter cycles xchg is
> >> better.
> >>
> >> On Intel processors, xchg is so slow that it never is profitable to
> >> use it. The slowness takes on extreme values in the E-cores, with
> >> slowdowns by a factor >10 for cyc4 and cyc5.
> >
> >Youรขย€ย™d think both companies would be running similar kinds of
> >instruction workloads to find the things worth optimizing in their CPU
> >architectures. But perhaps not ...
> 
> Or maybe, given the structure of the renamer, an AMD engineer saw a
> relatively easy way to implement xchg efficiently, and did it, without
> first looking at how often xchg occurs in benchmark programs.  And at
> Intel, either no engineer thought about this, or the structure of the
> renamer makes an efficient implementation much harder.

Unlike Mainframes where sort is bread-and-butter operation, on PCs
(and similar) it is not.
 
> It makes me wonder, however, why cyc2xchg is more expensive than
> cyc2reg, though.  An easy implementation should be to decode xchg reg,
> reg into three mov reg, reg (i.e., what cyc2reg implements), where the
> spare register is a non-architectural register.  But on every measured
> Intel microarchitecture cyc2xchg is substantially slower than cyc2reg.
> 
> - anton
Technical Details
Message-ID: <1792017353-5857@newsgrouper.org>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!newsgrouper.org!.POSTED!not-for-mail
References: <2026Oct13.104347@mips.complang.tuwien.ac.at> <11ami2v$11dqu$3@dont-email.me> <2026Oct14.090023@mips.complang.tuwien.ac.at>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!newsgrouper.org!.POSTED!not-for-mail
From: MitchAlsup <user5857@newsgrouper.org.invalid>
Newsgroups: comp.arch
Subject: Re: Performance of xchg reg,reg
References: <2026Oct13.104347@mips.complang.tuwien.ac.at> <11ami2v$11dqu$3@dont-email.me> <2026Oct14.090023@mips.complang.tuwien.ac.at>
Date: Wed, 14 Oct 2026 22:35:53 GMT
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Message-ID: <1792017353-5857@newsgrouper.org>
Injection-Info: newsgrouper.org; mail-complaints-to="newsgrouper@yahoo.com"; posting-account=user5857
Injection-Date: Wed, 14 Oct 2026 22:35:53 GMT
User-Agent: Newsgrouper/0.9.0