On Mon, Jul 20, 2026 at 5:12 PM Maciej W. Rozycki <[email protected]> wrote: > > On Fri, 17 Jul 2026, Uros Bizjak wrote: > > > It is better to use the form that clobbers flags reg and leave insn > > selection > > to the compiler via preferred_for_* machinery. This choice also makes > > "improve register allocation" peephole2 obsolete. > > Hmm... > > > diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md > > index 3aa8c926094..fbaf28017bb 100644 > > --- a/gcc/config/i386/i386.md > > +++ b/gcc/config/i386/i386.md > > @@ -23665,100 +23669,91 @@ (define_expand "bswaphi2" > > }) > > > > (define_insn "*bswaphi2_movbe" > > - [(set (match_operand:HI 0 "nonimmediate_operand" "=Q,r,m") > > - (bswap:HI (match_operand:HI 1 "nonimmediate_operand" "0,m,r")))] > > + [(set (match_operand:HI 0 "nonimmediate_operand" "=Q,r,r,m") > > + (bswap:HI (match_operand:HI 1 "nonimmediate_operand" "0,0,m,r"))) > > + (clobber (reg:CC FLAGS_REG))] > > "TARGET_MOVBE > > && !(MEM_P (operands[0]) && MEM_P (operands[1]))" > > "@ > > xchg{b}\t{%h0, %b0|%b0, %h0} > > + rol{w}\t{$8, %0|%0, 8} > > movbe{w}\t{%1, %0|%0, %1} > > movbe{w}\t{%1, %0|%0, %1}" > > ... would it be possible to tell the middle end via constraints that > flags aren't necessarily clobbered, i.e.: > > (clobber (match_scratch:CC 2 "=X,Bf,X,X))] > > (here and elsewhere) so as to avoid pretending there is an inexistent data > dependency and consequently possibly improve the code flow? Or is it a > completely unreasonable idea that won't work in this case?
Unfortunately, this won't work, because clobber is also processed well before reload. The only solution is to have several different insn patterns, but considering that XCHGB is used only for obsolete pentium4 does not warrant clobber-less patterns. Uros.
