Hi!
While in this case it is not an assemble failure nor wrong-code,
because say xchgl %eax, %edx and xchg eax, edx do the same thing,
they are encoded differently, so if we want consistency between
-masm=att and -masm=intel emitted code (my understanding is that
is what is Zdenek testing right now, fuzzing code, compiling
with both -masm=att and -masm=intel and making sure if the former
assembles, the latter does too and they result in identical
*.o files), we should use different order of the operands
even here (and it doesn't matter which order we pick).
Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
I've grepped the *.md files with
grep '\\t%[0-9], %[0-9]' *.md | grep -v '%0, %0'
i386.md: "xchg{<imodesuffix>}\t%1, %0"
i386.md: xchg{<imodesuffix>}\t%1, %0
i386.md: "wrss<mskmodesuffix>\t%0, %1"
i386.md: "wruss<mskmodesuffix>\t%0, %1"
(before this and PR124366 fix) and later on also with
grep '\\t%[a-z0-9_<>]*[0-9], %[a-z0-9_<>]*[0-9]' *.md | grep -v '%0, %0'
and checked all the output and haven't found anything else problematic.
2026-03-05 Jakub Jelinek <[email protected]>
* config/i386/i386.md (swap<mode>): Swap operand order for
-masm=intel.
--- gcc/config/i386/i386.md.jj 2026-03-03 15:47:04.230275241 +0100
+++ gcc/config/i386/i386.md 2026-03-04 21:52:33.409720768 +0100
@@ -3360,7 +3360,7 @@ (define_insn "swap<mode>"
(set (match_dup 1)
(match_dup 0))]
""
- "xchg{<imodesuffix>}\t%1, %0"
+ "xchg{<imodesuffix>}\t{%1, %0|%0, %1}"
[(set_attr "type" "imov")
(set_attr "mode" "<MODE>")
(set_attr "pent_pair" "np")
@@ -3375,8 +3375,8 @@ (define_insn "*swap<mode>"
(match_dup 0))]
""
"@
- xchg{<imodesuffix>}\t%1, %0
- xchg{l}\t%k1, %k0"
+ xchg{<imodesuffix>}\t{%1, %0|%0, %1}
+ xchg{l}\t{%k1, %k0|%k0, %k1}"
[(set_attr "type" "imov")
(set_attr "mode" "<MODE>,SI")
(set (attr "preferred_for_size")
Jakub