https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126433

--- Comment #2 from Uroš Bizjak <ubizjak at gmail dot com> ---
(In reply to Uroš Bizjak from comment #1)
> Created attachment 65143 [details]
> Patch in testing.

Hm, this won't fly... it hits some GCC oddity:

(define_insn "*bswaphi2"
  [(set (match_operand:HI 0 "register_operand" "=Q,r")
       (bswap:HI (match_operand:HI 1 "register_operand" "0,0")))
...
  "@
    xchg{b}\t{%h0, %b0|%b0, %h0}
    rol{w}\t{$8, %0|%0, 8}"
...
   (set (attr "preferred_for_speed")
     (cond [(eq_attr "alternative" "0")
              (symbol_ref "TARGET_USE_XCHGB")
            (eq_attr "alternative" "1")
              (symbol_ref "!TARGET_USE_XCHGB")
           ]
           (symbol_ref "true")))])

If an alternative is a subset of some other alternative ("Q" is a subset of "r"
in the above pattern), then the compiler will *still* emit XCHG alternative 0
even if it is disabled by targeting !TARGET_USE_XCHGB target.

I will implement this functionality the hard way by providing several
target-dependant patterns. But the issue is surprising at least.

Reply via email to