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?
Maciej