Re: [PATCH 1/2] x86: optimize XCHG to MOV for same-register forms
Jan Beulich <[email protected]>
| Newsgroups | gmane.comp.gnu.binutils |
|---|---|
| Message-ID | <[email protected]> |
On 07.07.2026 19:18, Christian Ludloff wrote: >> Assembler optimization is intended primarily for hand-written code. > > Uhm, hand-written assembler code is the prime example > for *not* wanting specified instruction FOO suddenly turn > into emitted instruction BAR. Then you simply don't pass -O..., and you'll get exactly what you've written. Well, almost - already prior to the introduction of -O we did a very small set (one or two) of optimizations. Iirc even nowadays we continue to do these irrespective of whether -O is passed. > If I code XCHG, then I mean to get XCHG. Had I wanted > MOV, I'd have coded MOV. XCHG may be a less likely example, but as I said elsewhere - I've seen all sorts of code (in particular in BIOSes) that is inefficient. The most prominent perhaps being LEA where MOV can be used. > What is the expected worthwhile benefit of the proposed > transformations in practice? Less execution overhead (uniformly for all optimizations), due to varying aspects (code size, decode, execution resources needed). Imo long term all inefficiencies in encodings may (and perhaps should) be subject to replacement. If this isn't wanted, stringent criteria for optimization to actually carry out would need writing down. Jan