]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
xtensa: Implement bswaphi2 insn pattern
authorTakayuki 'January June' Suwa <jjsuwa_sys3175@yahoo.co.jp>
Sun, 29 May 2022 10:44:32 +0000 (19:44 +0900)
committerMax Filippov <jcmvbkbc@gmail.com>
Thu, 9 Jun 2022 22:07:08 +0000 (15:07 -0700)
This patch adds bswaphi2 insn pattern that is one instruction less than the
default expansion.

gcc/ChangeLog:

* config/xtensa/xtensa.md (bswaphi2): New insn pattern.

gcc/config/xtensa/xtensa.md

index 8a119038ba154c30822ecc25df39e53e176dadd4..abf4ad103467a98419b2a843437008bfb53e10fc 100644 (file)
 \f
 ;; Byte swap.
 
+(define_insn "bswaphi2"
+  [(set (match_operand:HI 0 "register_operand" "=a")
+       (bswap:HI (match_operand:HI 1 "register_operand" "r")))
+   (clobber (match_scratch:HI 2 "=&a"))]
+  ""
+  "extui\t%2, %1, 8, 8\;slli\t%0, %1, 8\;or\t%0, %0, %2"
+   [(set_attr "type"   "arith")
+    (set_attr "mode"   "HI")
+    (set_attr "length" "9")])
+
 (define_expand "bswapsi2"
   [(set (match_operand:SI 0 "register_operand" "")
         (bswap:SI (match_operand:SI 1 "register_operand" "")))]