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]

Register allocation problem?


Hello,

I have a problem I believe is related to register allocation in GCC.
The RTL code for this function:

  int foo (int x, int y) { return -y; }

looks like this before register allocation (dump 18.regmove):

  (insn 4 23 5 (set (reg/v:SI 23)
          (reg:SI 2 2)) 48 {movsi} (nil)
      (expr_list:REG_DEAD (reg:SI 2 2)
          (nil)))
  
  (note 5 4 12 NOTE_INSN_FUNCTION_BEG)
  
  (insn 12 5 16 (set (reg:SI 24)
          (neg:SI (reg/v:SI 23))) 87 {negsi2} (insn_list 4 (nil))
      (expr_list:REG_DEAD (reg/v:SI 23)
          (nil)))
  
  (note 16 12 19 NOTE_INSN_FUNCTION_END)
  
  (insn 19 16 22 (set (reg/i:SI 1 1)
          (reg:SI 24)) 48 {movsi} (insn_list 12 (nil))
      (expr_list:REG_DEAD (reg:SI 24)
          (nil)))
  
  (insn 22 19 0 (use (reg/i:SI 1 1)) -1 (insn_list 19 (nil))
      (nil))

And after register allocation (dump 21.greg):

  (insn 4 23 5 (set (reg/v:SI 1 1 [23])
          (reg:SI 2 2)) 48 {movsi} (nil)
      (nil))
  
  (note 5 4 12 NOTE_INSN_FUNCTION_BEG)
  
  (insn 12 5 16 (set (reg:SI 1 1 [24])
          (neg:SI (reg/v:SI 1 1 [23]))) 87 {negsi2} (insn_list 4 (nil))
      (nil))
  
  (note 16 12 19 NOTE_INSN_FUNCTION_END)
  
  (insn 19 16 22 (set (reg/i:SI 1 1)
          (reg:SI 1 1 [24])) 48 {movsi} (insn_list 12 (nil))
      (nil))
  
  (insn 22 19 26 (use (reg/i:SI 1 1)) -1 (insn_list 19 (nil))
      (nil))

In the end, there is an unnecessary move (insn 4) that wouldn't have
been there is pseudo 23 was put in hard reg 2 instead of 1.

Is there a way to improve this situation?


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