* Query regarding RTL Template in i386.md
@ 2005-09-29 6:39 Piyush Porwal
2005-09-29 18:00 ` Ian Lance Taylor
0 siblings, 1 reply; 2+ messages in thread
From: Piyush Porwal @ 2005-09-29 6:39 UTC (permalink / raw)
To: gcc-help
Hello everyone,
I would like to request your help in a specific matter which
relates to i386.md (GCC-4.0).
I find it difficult to understand the motivation to use
two or more 'set' constructs in an RTL template. Here is an example
from i386.md (GCC-4.0) file (only RTL Template is shown):
----------------------------------------------------------------------
(define_insn "*adddi_2_rex64"
[(set (reg FLAGS_REG)
(compare
(plus:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
(match_operand:DI 2 "x86_64_general_operand" "rme,re"))
(const_int 0)))
(set (match_operand:DI 0 "nonimmediate_operand" "=r,rm")
(plus:DI (match_dup 1) (match_dup 2)))]
----------------------------------------------------------------------
As visible in the template, it contains two 'set' operators. A few
questions that come to mind are:
- the use of multiple 'set' constructs: in particular, what
aspect(s) of the instruction set, or the target machine, guides us
to choose such a construction,
- how does one 'evaluate' the benefits if other patterns with one
'set' are possible, (this particularly pertains to the decision of
where to place the insn pattern in the overall machine
description, since GCC uses a 'first hit' approach).
An example C code fragment would be extremely useful, if possible.
I deeply appreciate the time and effort you would be spending in
replying. I will be very thankful if you can provide me with your expert
guidance and thoughts.
-regards
__________________________________________
Piyush Porwal
CSE - M.Tech.
Indian Institute of Technology, Bombay
India
http://www.cse.iitb.ac.in/~porwalpiyush
__________________________________________
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Query regarding RTL Template in i386.md
2005-09-29 6:39 Query regarding RTL Template in i386.md Piyush Porwal
@ 2005-09-29 18:00 ` Ian Lance Taylor
0 siblings, 0 replies; 2+ messages in thread
From: Ian Lance Taylor @ 2005-09-29 18:00 UTC (permalink / raw)
To: Piyush Porwal; +Cc: gcc-help
Piyush Porwal <porwalpiyush@cse.iitb.ac.in> writes:
> I would like to request your help in a specific matter which
> relates to i386.md (GCC-4.0).
A question like this, a specific question about the gcc source code,
could reasonably have gone to gcc@gcc.gnu.org rather than
gcc-help@gcc.gnu.org. But gcc-help is fine too.
> ----------------------------------------------------------------------
> (define_insn "*adddi_2_rex64"
> [(set (reg FLAGS_REG)
> (compare
> (plus:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
> (match_operand:DI 2 "x86_64_general_operand" "rme,re"))
> (const_int 0)))
> (set (match_operand:DI 0 "nonimmediate_operand" "=r,rm")
> (plus:DI (match_dup 1) (match_dup 2)))]
> ----------------------------------------------------------------------
>
> As visible in the template, it contains two 'set' operators. A few
> questions that come to mind are:
>
> - the use of multiple 'set' constructs: in particular, what
> aspect(s) of the instruction set, or the target machine, guides us
> to choose such a construction,
If a single machine instruction changes two registers, then it is
reasonable and normal to use a parallel with two sets, as above. This
is typical of i386 arithmetic instructions: they set a result
register, and they also set the condition code flags. This is
generally the case on processors with condition codes. Many RISC
processors, by comparison, do not have condition codes, and instead
have comparison instructions which set specific registers.
> - how does one 'evaluate' the benefits if other patterns with one
> 'set' are possible, (this particularly pertains to the decision of
> where to place the insn pattern in the overall machine
> description, since GCC uses a 'first hit' approach).
I'm not sure I entirely understand your question. If the combine pass
sees that there are multiple sets in an insn, and, say, sees that all
but one are dead, and is able to find a insn pattern which matches the
single live set, then it will use that insn pattern. Similarly, if
combine sees two related single-set insns, and finds an insn pattern
which can do both in one pattern, it will replace both of them with
the single pattern. In neither case does the ordering matter. Other
than those examples, the compiler rarely chooses between single-set
insns and multi-set insns.
Ian
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2005-09-29 18:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-09-29 6:39 Query regarding RTL Template in i386.md Piyush Porwal
2005-09-29 18:00 ` Ian Lance Taylor
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).