This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[Patch, moxie] Use xor instead of load immediate to get 0 into a register
- From: Anthony Green <green at moxielogic dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 09 Sep 2009 18:04:50 -0400
- Subject: [Patch, moxie] Use xor instead of load immediate to get 0 into a register
I'm committing the following patch to the moxie port to use the short
"xor $rX, $rX" instruction to load register $rX with 0 instead of the
longer load immediate instruction (ldi.l $rX, 0).
AG
2009-09-09 Anthony Green <green@moxielogic.com>
* config/moxie/moxie.md (*movsi, *movhi, *movqi): Use xor to load
the constant 0 when appropriate.
* config/moxie/constraints.md: Add constraint O.
Index: gcc/config/moxie/moxie.md
===================================================================
--- gcc/config/moxie/moxie.md (revision 149693)
+++ gcc/config/moxie/moxie.md (working copy)
@@ -223,11 +223,12 @@
}")
(define_insn "*movsi"
- [(set (match_operand:SI 0 "general_operand" "=r,r,W,A,r,r,B,r")
- (match_operand:SI 1 "moxie_general_movsrc_operand" "r,i,r,r,W,A,r,B"))]
+ [(set (match_operand:SI 0 "general_operand" "=r,r,r,W,A,r,r,B,r")
+ (match_operand:SI 1 "moxie_general_movsrc_operand" "O,r,i,r,r,W,A,r,B"))]
"register_operand (operands[0], SImode)
|| register_operand (operands[1], SImode)"
"@
+ xor %0, %0
mov %0, %1
ldi.l %0, %1
st.l %0, %1
@@ -236,7 +237,7 @@
lda.l %0, %1
sto.l %0, %1
ldo.l %0, %1"
- [(set_attr "length" "2,6,2,6,2,6,6,6")])
+ [(set_attr "length" "2,2,6,2,6,2,6,6,6")])
(define_expand "movqi"
[(set (match_operand:QI 0 "general_operand" "")
@@ -250,11 +251,12 @@
}")
(define_insn "*movqi"
- [(set (match_operand:QI 0 "general_operand" "=r,r,W,A,r,r,B,r")
- (match_operand:QI 1 "moxie_general_movsrc_operand" "r,i,r,r,W,A,r,B"))]
+ [(set (match_operand:QI 0 "general_operand" "=r,r,r,W,A,r,r,B,r")
+ (match_operand:QI 1 "moxie_general_movsrc_operand" "O,r,i,r,r,W,A,r,B"))]
"register_operand (operands[0], QImode)
|| register_operand (operands[1], QImode)"
"@
+ xor %0, %0
mov %0, %1
ldi.b %0, %1
st.b %0, %1
@@ -263,7 +265,7 @@
lda.b %0, %1
sto.b %0, %1
ldo.b %0, %1"
- [(set_attr "length" "2,6,2,6,2,6,6,6")])
+ [(set_attr "length" "2,2,6,2,6,2,6,6,6")])
(define_expand "movhi"
[(set (match_operand:HI 0 "general_operand" "")
@@ -277,11 +279,12 @@
}")
(define_insn "*movhi"
- [(set (match_operand:HI 0 "general_operand" "=r,r,W,A,r,r,B,r")
- (match_operand:HI 1 "moxie_general_movsrc_operand" "r,i,r,r,W,A,r,B"))]
+ [(set (match_operand:HI 0 "general_operand" "=r,r,r,W,A,r,r,B,r")
+ (match_operand:HI 1 "moxie_general_movsrc_operand" "O,r,i,r,r,W,A,r,B"))]
"(register_operand (operands[0], HImode)
|| register_operand (operands[1], HImode))"
"@
+ xor %0, %0
mov %0, %1
ldi.s %0, %1
st.s %0, %1
@@ -290,7 +293,7 @@
lda.s %0, %1
sto.s %0, %1
ldo.s %0, %1"
- [(set_attr "length" "2,6,2,6,2,6,6,6")])
+ [(set_attr "length" "2,2,6,2,6,2,6,6,6")])
;; -------------------------------------------------------------------------
;; Compare instructions
Index: gcc/config/moxie/constraints.md
===================================================================
--- gcc/config/moxie/constraints.md (revision 149693)
+++ gcc/config/moxie/constraints.md (working copy)
@@ -40,6 +40,11 @@
(match_test "REG_P (XEXP (op, 0))
&& REGNO_OK_FOR_BASE_P (REGNO (XEXP (op, 0)))")))
+(define_constraint "O"
+ "The constant zero"
+ (and (match_code "const_int")
+ (match_test "ival == 0")))
+
(define_constraint "I"
"An 8-bit constant (0..255)"
(and (match_code "const_int")
@@ -49,4 +54,3 @@
"A constant -(0..255)"
(and (match_code "const_int")
(match_test "ival >= -255 && ival <= 0")))
-