This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Requesting scratch register


> Hi all,
> 
> As written in MD Documentation, the pattern (clobber 
> (match_scratch)) would request for a scratch register for use in 
> particular insn. Is there any way to know if the scratch register 
> is available for use. I would clarify on my point. I'm generating 
> an insn
> 
> (parallel [(.............) (clobber (match_scratch:SI))])
> 
> That would give me a little improvement. But I don't want to 
> increase the register pressure. I would like to generate the above 
> insn in the situation where I could find a free scratch 
> register.
> 

Add a peephole2 that uses the scratch and generates the more efficient 
sequence.  Use a pattern without the scratch prior to register allocation.

Alternatively, you might be able to do this with register constraints; if 
an alternative doesn't need a scratch register, just use X in the 
constraint for that alternative.  Something like

(set (match_operand:SI 0 "register_operand" "r,r")
     (OP:SI (match_operand:SI 1 "register_operand" "r,r")
	    (match_operand:SI 2 "some_constraint" "r,I"))) ; I is some magic 
constant
; Scratch only needed if op 2 is a constant
(clobber (match_operand:SI 3 "match_scratch" "X,r"))

R.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]