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]

Problem in global register allocation


Hi folks,

I have a problem where the global register allocation pass clobbers the content of a
register.  I'm using the 09.22 snapshot.  The target is an 8-bit machine.  The problem is
shown below; first the RTL after the local register allocation pass:

(insn 371 369 372 (set (reg:QI 109)
        (mem/s:QI (plus:HI (reg:HI 93)
                (const_int 5)))) 0 {movqi} (nil)
    (nil))

(insn 372 371 374 (parallel[ 
            (set (reg/v:HI 25)
                (ashift:HI (reg/v:HI 25)
                    (reg:QI 109)))
            (clobber (reg:QI 109))
        ] ) 83 {*ashlhi3} (insn_list 371 (nil))
    (expr_list:REG_UNUSED (reg:QI 109)
        (expr_list:REG_EQUAL (ashift:HI (reg/v:HI 25)
                (mem/s:QI (plus:HI (reg:HI 93)
                        (const_int 5))))
            (nil))))

 ===> becomes after global register allocation:

(insn 465 371 372 (set (reg:QI 2 %r2)
        (mem:QI (plus:HI (reg:HI 13 %i3h)
                (const_int 12)))) -1 (nil)
    (nil))

(insn:HI 372 465 463 (parallel[ 
            (set (reg:HI 1 %r3)
                (ashift:HI (mem:HI (plus:HI (reg:HI 13 %i3h)
                            (const_int 10)))
                    (reg:QI 2 %r2)))
            (clobber (reg:QI 2 %r2))
        ] ) 83 {*ashlhi3} (insn_list 371 (nil))
    (expr_list:REG_UNUSED (mem:QI (plus:HI (reg:HI 13 %i3h)
                (const_int 12)))
        (expr_list:REG_EQUAL (ashift:HI (mem:HI (plus:HI (reg:HI 13 %i3h)
                        (const_int 10)))
                (mem/s:QI (plus:HI (reg:HI 11 %i2h)
                        (const_int 5))))
            (nil))))

Since this is an 8-bit machine, and given the register ordering, hard register (reg:HI 1 %r3)
is composed of registers (reg:QI 1 %r3) and (reg:QI 2 %r2).  The problem is that (reg:QI 2 %r2)
is also used and clobbered as specified in the instruction.

Can anybody point me in the direction of where the problem might come from (I find the
global.c and reload*.c files rather obscure...)?

Here is the left shift template FWIW.

(define_insn "*ashlhi3"
  [(set (match_operand:HI 0 "register_operand" "=r")
	(ashift:HI (match_operand:HI 1 "general_operand" "g")
		   (match_operand:QI 2 "nonmemory_operand" "ri")))
   (clobber (match_dup 2))]
  ""
  "*
{
  return output_left_shift(insn, operands, 0);
}")


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