This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Fix to mn10300 cmpsi pattern
- To: Alexandre Oliva <aoliva at redhat dot com>
- Subject: Re: Fix to mn10300 cmpsi pattern
- From: Matt Hiller <hiller at redhat dot com>
- Date: Tue, 27 Mar 2001 17:55:59 -0800 (PST)
- cc: gcc-patches at gcc dot gnu dot org
On 27 Mar 2001, Alexandre Oliva wrote:
> > but %0 could be an address or extended register. How about btst
> > 0,d0 instead?
>
> Should be fine, with some comments explaining why it sets the flags
> correctly and why the actual register doesn't matter. Using a data
> register will in fact generate smaller code than using the
> extended-register version of btst introduced in AM33.
Okay. How's this?
Index: gcc/config/mn10300/mn10300.md
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/mn10300/mn10300.md,v
retrieving revision 1.38
diff -c -r1.38 mn10300.md
*** gcc/config/mn10300/mn10300.md 2000/12/06 03:56:43 1.38
--- gcc/config/mn10300/mn10300.md 2001/03/28 01:54:13
***************
*** 709,723 ****
"* return output_tst (operands[0], insn);"
[(set_attr "cc" "set_znv")])
(define_insn "cmpsi"
[(set (cc0)
(compare (match_operand:SI 0 "register_operand" "!*d*a*x,dax")
(match_operand:SI 1 "nonmemory_operand" "!*0,daxi")))]
""
"@
! add 0,%0
cmp %1,%0"
! [(set_attr "cc" "invert,compare")])
;; ----------------------------------------------------------------------
;; ADD INSTRUCTIONS
--- 709,731 ----
"* return output_tst (operands[0], insn);"
[(set_attr "cc" "set_znv")])
+ ;; Ordinarily, the cmp instruction will set the Z bit of cc0 to 1 if
+ ;; its operands hold equal values, but the operands of a cmp
+ ;; instruction must be distinct registers. In the case where we'd
+ ;; like to compare a register to itself, we can achieve this effect
+ ;; with a btst 0,d0 instead. (This will not alter the contents of d0
+ ;; but will have the proper effect on cc0. Using d0 is arbitrary; any
+ ;; data register would work.)
+
(define_insn "cmpsi"
[(set (cc0)
(compare (match_operand:SI 0 "register_operand" "!*d*a*x,dax")
(match_operand:SI 1 "nonmemory_operand" "!*0,daxi")))]
""
"@
! btst 0,d0
cmp %1,%0"
! [(set_attr "cc" "compare,compare")])
;; ----------------------------------------------------------------------
;; ADD INSTRUCTIONS