public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* The correct way to clobber a condition register for DFA scheduling
@ 2002-12-12  5:58 Dan Towner
  0 siblings, 0 replies; only message in thread
From: Dan Towner @ 2002-12-12  5:58 UTC (permalink / raw)
  To: gcc

Hi all,

I am writing a gcc port for a 16-bit DSP. Until now, I have ignored 
condition codes by using the cbranch pattern, and generating the flag, 
and branch in one output template. I have now split the branch into 
separate compare and branch instructions, which allows the two to be 
scheduled properly using the DFA scheduler. This also means that I have 
to ensure that other instruction patterns which affect the condition 
flags must now rewritten to correctly to show that they cannot be 
inserted between related compare and branch instructions. For example, I 
use the following pattern for an addhi3 instruction:

(define_insn "addhi3"
   [(set (match_operand:HI 0 "register_operand" "=r,r,r")
	(plus:HI (match_operand:HI 1 "register_operand" "r,r,r")
		 (match_operand:HI 2 "general_operand" "r,M,n")))
    (clobber (reg:CC CC_REGNUM))]
   ""
   "* return picochip_addhi3(operands);")

Note that the instruction clobbers the CC register. Unfortunately, when 
I run some tests, I get internal errors for a lot of my tests - the 
number of deaths of registers differs (as determine by 
sched-rgn.c:schedule_insns), but only in instructions which appear to be 
unrelated in the addhi pattern. I can cure these errors by removing the 
mode of the condition register, so that it becomes:

(clobber (reg CC_REGNUM))

I no longer get internal errors with this pattern, but then the DFA 
scheduler incorrectly schedules addhi3 instructions between related 
compare and branch instructions. This is only cured by using the :CC 
mode specifier, which leads back to the first problem.

Is the above pattern the correct way to clobber the CC register, or is 
there a better way?

Thanks,

Dan.

=============================================================================
Daniel Towner
picoChip Designs Ltd., Riverside Buildings, 108, Walcot Street, BATH, 
BA1 5BG
dant@picochip.com
07786 702589


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2002-12-12 13:11 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-12-12  5:58 The correct way to clobber a condition register for DFA scheduling Dan Towner

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).