RE: [Valgrind-developers] [PATCH 1/2] x86: optimize XCHG to MOV for same-register forms

"Jiang, Haochen" <[email protected]>
Newsgroups gmane.comp.gnu.binutils,gmane.comp.debugging.valgrind.devel
Message-ID <IA4PR11MB9009E47BDBB49CA7F43CC1B2ECF42@IA4PR11MB9009.namprd11.prod.outlook.com>
> From: Jan Beulich <[email protected]>
> Sent: Friday, July 3, 2026 2:24 PM
> 
> On 03.07.2026 08:09, Paul Floyd wrote:
> > On 2026-07-03 08:00, Jan Beulich wrote:
> >> On 03.07.2026 06:55, Paul Floyd wrote:
> >>> Would it be possible for gas to only do this transformation if the source
> and destination registers are different?
> >> When the registers are different, this transformation is invalid to do.
> >
> > OK so you are optimising a no-op. Does GCC use it as a no-op?

No, GCC won't use them as nop. GCC relies on Binutils how different
size of nops are generated eventually. GCC will only give hint on how
big the nops should be.

Thx,
Haochen

> 
> I don't expect so. In fact, my take is that -O... should not be used on
> compiler generated code. The compiler should do whatever optimizations
> are possible / sensible, and it should not emit code which can (easily)
> further be optimized. (Easily because the assembler really only does
> very simple and pretty obvious transformations.)
> 
> I can see that there may be a desire to optimize asm()-generated code.
> That imo shouldn't be done by passing -Wa,-O... but rather by some
> other, to be invented machinery. (We could tie it to the #APP / #NO_APP
> markers that the compiler emits, for example.)
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.