[PATCH] x86: Disable XCHG to MOV optimization

H.J. Lu hjl.tools@gmail.com
Mon Jul 13 20:55:11 GMT 2026


On Mon, Jul 13, 2026 at 11:42 PM Jan Beulich <jbeulich@suse.com> wrote:
>
> On 13.07.2026 17:31, H.J. Lu wrote:
> > On Mon, Jul 13, 2026 at 11:20 PM Jan Beulich <jbeulich@suse.com> wrote:
> >>
> >> On 13.07.2026 17:10, H.J. Lu wrote:
> >>> On Mon, Jul 13, 2026 at 11:03 PM Jan Beulich <jbeulich@suse.com> wrote:
> >>>>
> >>>> On 13.07.2026 14:08, H.J. Lu wrote:
> >>>>> I am going to check this patch into master as well as 2.47 branch.
> >>>>> I added optimize_for_unsafe, which is 0, and moved XCHG to MOV
> >>>>> optimization under it.  We can add something like -Ounsafe later.
> >>>>
> >>>> But this is wrong, the optimization itself isn't unsafe. Please can we
> >>>
> >>> You can change it to a different name.  But -O on master must work with
> >>> today's valgrind.
> >>
> >> That's your position. I continue to fail to see why -O needs to work on
> >> anything (valgrind or not) that depends on getting to see specific
> >> encodings for certain insns. Such uses of -O are simply wrong. Undoing
> >
> > You can add a different option.  -O should work for all applications today.
>
> Again - no. It simply can't. (Ftaod when I say -O in this discussion, I
> generally mean all its forms.)
>

My original design goal of -O is 100% safe for any applications.  It
is too bad we don't agree on it.  Here is the final patch I am checking
in.

-- 
H.J.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-x86-Disable-XCHG-to-MOV-optimization.patch
Type: text/x-patch
Size: 7085 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20260714/f864c40d/attachment-0001.bin>


More information about the Binutils mailing list