Article View: comp.arch
Article #184Re: Performance of xchg reg,reg
From: Anton Ertl
Date: Sun, 18 Oct 2026 15:08
Date: Sun, 18 Oct 2026 15:08
63 lines
3880 bytes
3880 bytes
MitchAlsup <user5857@newsgrouper.org.invalid> writes: >cross@spitfire.i.gajendra.net (Dan Cross) posted: >> What I'm saying is that, as written, the bits in the `LOCK` >> description above _could_ be interpreted to mean that _any_ >> `XCHG` will always assert the `LOCK#` signal, including an >> `XCHG` that does not touch memory at all. The "Why?" was >> rhetorical, as in, "Why would the system do that?" For example, >> if one wrote, `xchg %ecx, %eax`, why should that assert `LOCK#`? >> Truly I don't know, and I was just speculating. > >Writing high quality documentation is fundamentally hard. I don't think that's the issue here. They just did not limit the sentence "The XCHG instruction always asserts the LOCK# signal regardless of the presence or absence of the LOCK prefix." to XCHG instructions with memory operands. That would be easy to fix, but they did not. And Chris M. Thomasson understood it as including XCHG reg, reg. My guess is that it is easy to fix in principle, but you have to deal with all kinds of red tape for such a fix, so unless there is good reason, you don't do it. This sentence already exists in my 1994-vintage Pentium Processor User's Manual Vol. 3. There it is preceeded by: |The LOCK prefix functions only with the following instructions: | |... |XCHG reg, mem |XCHG mem, reg |... With no occurence of XCHG reg, reg anywhere. But, OTOH, this is not really a contradiction to the sentence "The XCHG instruction always asserts the LOCK# signal regardless of the presence or absence of the LOCK prefix." >What they wrote may have well been exactly what the HW did back then >but somewhere between then and now architects and designers figured >out other ways and nobody went back to fully scrub the documents. Actually <https://www.felixcloutier.com/x86/lock> then says that "Beginning with the P6 family processors, when [...], the LOCK# signal is generally not asserted [...]" and still explains mechanism, finally saying "the operation is carried out atomically with regards to memory." If they wrote that as the description of the LOCK prefix, much of the rest could be deleted. Generally, an architecture manual should talk about architectural effects, not about asserted signals. The operational semantics given in <https://www.felixcloutier.com/x86/lock> is: | AssertLOCK#(DurationOfAccompaningInstruction); Oh boy. - anton -- 'Anyone trying for "industrial quality" ISA should avoid undefined behavior.' Mitch Alsup, <c17fcd89-f024-40e7-a594-88a85ac10d20o@googlegroups.com>
Technical Details
Message-ID:
<2026Oct18.170823@mips.complang.tuwien.ac.at>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!.POSTED!not-for-mailReferences:
<2026Oct13.104347@mips.complang.tuwien.ac.at> <11au1vu$3ks5m$2@dont-email.me> <11aunpn$8c6$1@reader2.panix.com> <1792257076-5857@newsgrouper.org> <11b0bd3$b5b$1@reader2.panix.com> <1792265982-5857@newsgrouper.org>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!.POSTED!not-for-mail From: anton@mips.complang.tuwien.ac.at (Anton Ertl) Newsgroups: comp.arch Subject: Re: Performance of xchg reg,reg Date: Sun, 18 Oct 2026 15:08:23 GMT Organization: Institut fuer Computersprachen, Technische Universitaet Wien Lines: 63 Message-ID: <2026Oct18.170823@mips.complang.tuwien.ac.at> References: <2026Oct13.104347@mips.complang.tuwien.ac.at> <11au1vu$3ks5m$2@dont-email.me> <11aunpn$8c6$1@reader2.panix.com> <1792257076-5857@newsgrouper.org> <11b0bd3$b5b$1@reader2.panix.com> <1792265982-5857@newsgrouper.org> Injection-Date: Sun, 18 Oct 2026 15:29:46 +0000 (UTC) Injection-Info: dont-email.me; logging-data="1312964"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX194fwYWseRAcSzH5D6y7F2g"; posting-host="ba7b1f5472640d23e9d2e2c2f24e9c05" Cancel-Lock: sha1:13xph0BLpKXoPMNMvUymtRxusfI= sha256:IRVQppPvh4TLhOox3k4scxHOwuX/CSlbk7SZDdqyfmw= sha1:VVyevb38vyxrpDR8I1hja+E+ENI= sha256:7VbKDATp344wSLnX0uNdHJk9kQm5kQ/2ko1GaJBevvU= X-newsreader: xrn 10.11