This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: PATCH for [ARM] subsequent use of plus and minus operators could be improved
- From: Richard Earnshaw <rearnsha at arm dot com>
- To: Zack Weinberg <zack at codesourcery dot com>
- Cc: Richard dot Earnshaw at arm dot com, Gábor Lóki <alga at rgai dot hu>, gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 16 Apr 2003 18:07:14 +0100
- Subject: Re: PATCH for [ARM] subsequent use of plus and minus operators could be improved
- Organization: ARM Ltd.
- Reply-to: Richard dot Earnshaw at arm dot com
> Richard Earnshaw <rearnsha at arm dot com> writes:
>
> >> > + /* Try to transform
> >> > + (set (regX) (plus\minus (regY) (constA)))
> >> > + (set (regX) (plus\minus (regX) (constB)))
> >> > + to
> >> > + (set (regX) (plus\minus (regY) (constA +\- constB))) */
> >>
> >> You should use forward slashes (/) here, not backslashes (\).
> >
> > In fact, because of canonicalization there should never be a MINUS with a
> > constant as the second operand -- this should always be transformed into
> > addition of the negated constant. So there's no need to check for that
> > case.
>
> What if (minus (reg) (imm)) is a valid insn but (plus (reg) (-imm))
> isn't?
>
> zw
Then you've got a broken machine description. This is a standard
canonicalization -- you have to handle this case when emitting
instructions. For example on ARM we have:
(define_insn_and_split "*arm_addsi3"
[(set (match_operand:SI 0 "s_register_operand" "=r,r,r")
(plus:SI (match_operand:SI 1 "s_register_operand" "%r,r,r")
(match_operand:SI 2 "reg_or_int_operand" "rI,L,?n")))]
"TARGET_ARM"
"@
add%?\\t%0, %1, %2
sub%?\\t%0, %1, #%n2
#"
Note the second alternative matches the "negative constant" case.
R.