This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
m68k: add bswapsi2 expander
- From: Andreas Schwab <schwab at linux-m68k dot org>
- To: gcc-patches at gcc dot gnu dot org
- Date: Thu, 12 Apr 2012 00:03:05 +0200
- Subject: m68k: add bswapsi2 expander
The default expansion of bswapsi2 (and bswapdi2) is pretty suboptimal.
Tested on m68k-linux.
Andreas.
* config/m68k/m68k.md (rotrhi3+1): Name it rotrhi_lowpart.
(bswapsi2): New expander.
diff --git a/gcc/config/m68k/m68k.md b/gcc/config/m68k/m68k.md
index e4b4b59..8104e75 100644
--- a/gcc/config/m68k/m68k.md
+++ b/gcc/config/m68k/m68k.md
@@ -1,6 +1,6 @@
;;- Machine description for GNU compiler, Motorola 68000 Version
;; Copyright (C) 1987, 1988, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2001,
-;; 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
+;; 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2012
;; Free Software Foundation, Inc.
;; This file is part of GCC.
@@ -5475,7 +5475,7 @@
"!TARGET_COLDFIRE"
"ror%.w %2,%0")
-(define_insn ""
+(define_insn "rotrhi_lowpart"
[(set (strict_low_part (match_operand:HI 0 "register_operand" "+d"))
(rotatert:HI (match_dup 0)
(match_operand:HI 1 "general_operand" "dI")))]
@@ -5495,6 +5495,19 @@
(match_operand:QI 1 "general_operand" "dI")))]
"!TARGET_COLDFIRE"
"ror%.b %1,%0")
+
+(define_expand "bswapsi2"
+ [(set (match_operand:SI 0 "register_operand")
+ (bswap:SI (match_operand:SI 1 "register_operand")))]
+ "!TARGET_COLDFIRE"
+{
+ rtx x = operands[0];
+ emit_move_insn (x, operands[1]);
+ emit_insn (gen_rotrhi_lowpart (gen_lowpart (HImode, x), GEN_INT (8)));
+ emit_insn (gen_rotlsi3 (x, x, GEN_INT (16)));
+ emit_insn (gen_rotrhi_lowpart (gen_lowpart (HImode, x), GEN_INT (8)));
+ DONE;
+})
;; Bit set/clear in memory byte.
--
1.7.10
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."