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]

Q. How to get better global register allocation?


Hi,

I working on a port based on 2.95.x (yep it's old) and I'm trying to guide the
global register allocator to produce better register allocations.

The registers can be divided into 4 classes A, B, C and D depending on which
functional unit they belong. There are a number of restrictions on which
register combinations are valid depending on the instruction and addressing
modes.

Given the following pseudo-rtl

                  (set (reg:SI 12) (...))
		  (set (reg:SI 22) (...))

(code_label 1)

                  (set (mem:SI (post_inc:SI (reg:SI 12))) (reg:SI 22))
		
                  (set (pc) (label_ref (code_label 1))
	

Local alloc decides to allocate A1 to pseudo 12 (A1 is the 1st free
register in REG_ALLOC_ORDER) global alloc then decides to allocate A2
to pseudo 22 (A2 is the 1st free register)

Now A2 is not a good register for pseudo 22 because the src and mem
cannot use registers from the same class. So we end up needing an
extra useless register-register move to fix things up.

What I'd like to be able to do is to tell the global register
allocator that for the (set (mem:SI ..) instruction *prefer* to
allocate reg 22 from any register class other than that of reg 12

What's the best way to guide the global register allocation into making
a good choice?

Looking at the .greg dump currently all regs preferer ALL_REGS so it's
picking the 1st free register A2.

Cheers
Graham


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