Article View: comp.arch
Article #200Re: Performance of xchg reg,reg
From: Dan Cross
Date: Sun, 18 Oct 2026 18:07
Date: Sun, 18 Oct 2026 18:07
64 lines
4146 bytes
4146 bytes
In article <20261018204738.00006b41@yahoo.com>,
Michael S <already5chosen@yahoo.com> wrote:
>On Sun, 18 Oct 2026 16:57:26 GMT
>anton@mips.complang.tuwien.ac.at (Anton Ertl) wrote:
>
>> Michael S <already5chosen@yahoo.com> writes:
>> >On Sun, 18 Oct 2026 15:08:23 GMT
>> >anton@mips.complang.tuwien.ac.at (Anton Ertl) wrote:
>> >> 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.
>> ...
>> >Frankly, I don't understand what both you and Dan Cross are talking
>> >about.
>> >I don't see how sentence from Intel's manual ("If a memory operand is
>> >referenced, the processor=E2=80=99s locking protocol is automatically
>> >implemented for the duration of the exchange operation, regardless of
>> >the presence or absence of the LOCK prefix or of the value of the
>> >IOPL") or sentence from AMD's manual ("If either operand references
>> >memory, the processor locks automatically, whether or not the LOCK
>> >prefix is used and independently of the value of IOPL.") can be
>> >pssibly misunderstood.
>>
>> Chris M. Thomasson wrote in <11arg45$2p70p$1@dont-email.me>:
>> |Well, for some reason the LOCK prefix is implied for XCHG.
>>
>> Given that the thread up to that point was aboyt XCHG reg, reg (and
>> according to the subject it still is), he seems to be an example that
>> what Intel wrote about XCHG and LOCK can be misunderstood. I looked
>> at the documentation and cited the relevant sentences in
>> <2026Oct16.075055@mips.complang.tuwien.ac.at>; most occurences clearly
>> refer only to XCHG where one operand is in memory. The exception is:
>>
>> |The XCHG instruction always asserts the LOCK# signal regardless of
>> the |presence or absence of the LOCK prefix.
>
>What is a source of this? Intel, AMD or somebody else?
This citation has been given many times now, but here it is yet
again: That is the last sentence of the third paragraph in the
"Description" section of the entry on the `LOCK` prefix in
Volume 2A of the Intel SDM, order number 253668-093US (September
2026), page 3-565. That volume can be downloaded from Intel at:
https://www.intel.com/content/www/us/en/developer/articles/technical/intel-sdm.html
>> And actually all the stuff about XCHG with memory operands does not
>> contradict this sentence. It could be understood as meaning that
>> while all the other aspects of locking don't apply to "XCHG reg, reg",
>> the assertion of the LOCK# signal still has to occur, and that's why
>> Intel processors implement a slow XCHG reg, reg. I don't think that's
>> what Intel intends and implements, but that's what a reading of their
>> manual implies.
>
>Somehow, it does not imply it to me.
Note that Anton said that it is an implication of _A_ reading
of the manual, not of _ALL_ readings of the manual. Hence why
it is ambiguous.
- Dan C.
Technical Details
Message-ID:
<11b31sv$av$1@reader2.panix.com>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!panix!.POSTED.spitfire.i.gajendra.net!not-for-mailReferences:
<2026Oct13.104347@mips.complang.tuwien.ac.at> <20261018184318.00000bee@yahoo.com> <2026Oct18.185726@mips.complang.tuwien.ac.at> <20261018204738.00006b41@yahoo.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!panix!.POSTED.spitfire.i.gajendra.net!not-for-mail From: cross@spitfire.i.gajendra.net (Dan Cross) Newsgroups: comp.arch Subject: Re: Performance of xchg reg,reg Date: Sun, 18 Oct 2026 18:07:27 -0000 (UTC) Organization: PANIX Public Access Internet and UNIX, NYC Message-ID: <11b31sv$av$1@reader2.panix.com> References: <2026Oct13.104347@mips.complang.tuwien.ac.at> <20261018184318.00000bee@yahoo.com> <2026Oct18.185726@mips.complang.tuwien.ac.at> <20261018204738.00006b41@yahoo.com> Injection-Date: Sun, 18 Oct 2026 18:07:27 -0000 (UTC) Injection-Info: reader2.panix.com; posting-host="spitfire.i.gajendra.net:166.84.136.80"; logging-data="351"; mail-complaints-to="abuse@panix.com" X-Newsreader: trn 4.0-test77 (Sep 1, 2010) Originator: cross@spitfire.i.gajendra.net (Dan Cross)