This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Need help with DImode hard regs in MD file
On Tue, Sep 14, 1999 at 01:46:22PM -0700, Richard Henderson wrote:
> On Tue, Sep 14, 1999 at 01:00:41AM -0500, Linas Vepstas wrote:
> > The 370 has an overflow-proof integer multiply: When multiplying
> > two SImode integers, the result is DImode.
>
> So it's really 32x32->64? Not 32x64->64?
>
> The later is what's being implied by your existing code.
>
> If 32x64->64 is true, you do not have a commutative operation,
> and the solution is to remove % from the constraints.
>
> If 32x32->64 is true, then you are golden and should be
> able to use a pattern like
>
>
> (define_insn "mulsidi3"
> [(set (match_operand:DI 0 "register_operand" "=d,d")
> (mult:DI (sign_extend:DI (match_operand:SI 1 "register_operand" "%0,0"))
> (sign_extend:DI (match_operand:SI 2 "general_operand" "r,g"))))]
> ""
> "@
> MR %0,%2
> M %0,%2")
>
> (define_expand "mulsi3"
> [(set (match_operand:SI 0 "register_operand" "")
> (mult:SI (match_operand:SI 1 "register_operand" "")
> (match_operand:SI 2 "general_operand" "")))]
> ""
> "
> {
> rtx r = gen_reg_rtx (DImode);
> emit_insn (gen_mulsidi3 (r, operands[1], operands[2]));
> emit_move_insn (operands[0], gen_lowpart (SImode, r));
> }")
It's been 24+ years since I last looked at the 3[679]0 architecture, so I don't
recall the specifics, but if you have a multiply by a constant that does
32x32->64 multiply you also need the pattern:
(define_insn "*mulsidi3_constant"
[(set (match_operand:DI 0 "register_operand" "=d")
(mult:DI (sign_extend:DI (match_operand:SI 1 "register_operand" 1 "0"))
(match_operand:DI 2 "const_int_operand" "i")))]
""
"M %0,%2")
Otherwise, the optimizer will never recognize a multiply that extends by a
constant (since the constant will never have a sign_extend wrapped around it).
> Note that mulsidi3 is useful to the optimizers in other
> ways too, so having it is a good thing.
Such as converting division of a constant into a multiplication.
>
> r~
--
Michael Meissner, Cygnus Solutions
PMB 198, 174 Littleton Road #3, Westford, Massachusetts 01886
email: meissner@cygnus.com phone: 978-486-9304 fax: 978-692-4482