* Teaching GCC about fmadd variant
@ 2002-04-22 1:27 Daniel Glastonbury
2002-04-22 7:38 ` Daniel Jacobowitz
0 siblings, 1 reply; 3+ messages in thread
From: Daniel Glastonbury @ 2002-04-22 1:27 UTC (permalink / raw)
To: gcc
Hi,
I'm looking for some help in teaching gcc how to use the fmadd variants
that my mips has. Unlike the mips IV madd instruction, this mips has a
variant that goes something like this:
mula fs, ft : ACC <- fs*ft
madda fs, ft : ACC <- ACC + fs*ft
madd fd, fs, ft: fd <- ACC + fs*ft
The problem is there is no general way to move to/from the ACC register.
I tried to teach gcc about a new register, the fp acc, and then specify insn
patterns to try match on a new register contraint, which I called F.
here are the example insn patterns I'm using:
(define_insn ""
[(set (match_operand:SF 0 "register_operand" "=f")
(plus:SF (mult:SF (match_operand:SF 1 "register_operand" "f")
(match_operand:SF 2 "register_operand" "f"))
(match_operand:SF 3 "register_operand" "F")))]
"TARGET_MIPS5900"
"madd.s\\t%0,%1,%2"
[(set_attr "type" "fmadd")
(set_attr "mode" "SF")
(set_attr "length" "1")])
(define_insn "R5900_maddas"
[(set (match_operand:SF 0 "register_operand" "=F")
(plus:SF (mult:SF (match_operand:SF 1 "register_operand" "f")
(match_operand:SF 2 "register_operand" "f"))
(match_operand:SF 3 "register_operand" "F")))]
"TARGET_MIPS5900"
"madda.s\\t%1,%2"
[(set_attr "type" "fmadd")
(set_attr "mode" "SF")
(set_attr "length" "1")])
(define_insn ""
[(set (match_operand:SF 0 "register_operand" "=F")
(mult:SF (match_operand:SF 1 "register_operand" "f")
(match_operand:SF 2 "register_operand" "f")))]
"TARGET_MIPS5900"
"mula.s\\t%1,%2"
[(set_attr "type" "fmadd")
(set_attr "mode" "SF")
(set_attr "length" "1")])
The problem is that I get an ICE because the compiler can't generate a
reload. I believe it's trying to load the computation from a regular
mult:SF into the ACC register.
Can anyone point me in the right direction. I've tried to glean as much
information as I could from the gcc internals manual, and from
mips.{c,h,md}, but I can't work out how to tell gcc to use a different
register.
I'm sorry if this is the wrong forum to ask this question.
thanks
Dan
--
Daniel Glastonbury, Senior Programmer, Ratbag Pty Ltd
Level 8, 63 Pirie Street, Adelaide, SA, Australia. 5000
T: +618 8223 5830 F: +618 8223 5746 W: http://www.ratbaggames.com
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Teaching GCC about fmadd variant
2002-04-22 1:27 Teaching GCC about fmadd variant Daniel Glastonbury
@ 2002-04-22 7:38 ` Daniel Jacobowitz
2002-04-23 5:43 ` Daniel Glastonbury
0 siblings, 1 reply; 3+ messages in thread
From: Daniel Jacobowitz @ 2002-04-22 7:38 UTC (permalink / raw)
To: Daniel Glastonbury; +Cc: gcc
On Mon, Apr 22, 2002 at 05:47:10PM +0930, Daniel Glastonbury wrote:
> Hi,
> I'm looking for some help in teaching gcc how to use the fmadd variants
> that my mips has. Unlike the mips IV madd instruction, this mips has a
> variant that goes something like this:
>
> mula fs, ft : ACC <- fs*ft
> madda fs, ft : ACC <- ACC + fs*ft
> madd fd, fs, ft: fd <- ACC + fs*ft
>
> The problem is there is no general way to move to/from the ACC register.
(Over my head, but) do you still get reasonable benefit from this if
you define simple-minded patterns to move from/to the accumulator?
i.e.:
load fs into ACC: load 1.0 into ft; mula fs, ft
load ACC into fd: load 0.0 into ft; madd fd, ft, ft
On the other hand, this won't help if you were actually seeing it use
the ACC unnecessarily. I believe that would need to be worked around
with costs. You're going to have problems with combine (discussed on
one GCC list, probably this one, a few weeks ago) getting fmadd to
work well, also.
--
Daniel Jacobowitz Carnegie Mellon University
MontaVista Software Debian GNU/Linux Developer
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Teaching GCC about fmadd variant
2002-04-22 7:38 ` Daniel Jacobowitz
@ 2002-04-23 5:43 ` Daniel Glastonbury
0 siblings, 0 replies; 3+ messages in thread
From: Daniel Glastonbury @ 2002-04-23 5:43 UTC (permalink / raw)
To: gcc
> (Over my head, but) do you still get reasonable benefit from this if
> you define simple-minded patterns to move from/to the accumulator?
> i.e.:
> load fs into ACC: load 1.0 into ft; mula fs, ft
> load ACC into fd: load 0.0 into ft; madd fd, ft, ft
>
> On the other hand, this won't help if you were actually seeing it use
> the ACC unnecessarily. I believe that would need to be worked around
> with costs. You're going to have problems with combine (discussed on
> one GCC list, probably this one, a few weeks ago) getting fmadd to
> work well, also.
Thanks for your reply. It seems everyone is busy with GCC 3.1.
How I was thinking of achieving this was by looking for patterns and trying
to `rewrite' the registers from $f1 to ACC, for example. Unfortunately I
don't really know where to do this. I'll keep nosing about the code and see
if I can understand how it all works. I'll look up the combine discussion
too.
thanks
Dan
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2002-04-23 12:03 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-04-22 1:27 Teaching GCC about fmadd variant Daniel Glastonbury
2002-04-22 7:38 ` Daniel Jacobowitz
2002-04-23 5:43 ` Daniel Glastonbury
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).