[Bug tree-optimization/126433] [17 Regression] 4% slowdown of imagick_r on Zen5 since r17-2486-g60b27d915e1474

ubizjak at gmail dot com via Gcc-bugs <[email protected]>
Newsgroups gmane.comp.gcc.bugs
Message-ID <[email protected]/bugzilla/>
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.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.