2008/6/19 Ian Lance Taylor <[EMAIL PROTECTED]>: > "Mohamed Shafi" <[EMAIL PROTECTED]> writes: > >> Before register renaming pass, callee registers was being used in the >> body of the code. Hence function prologue saved the register and >> epilogue restored the register. But register renaming pass removed >> this particular callee saved register.The output and code generation >> is proper, but there is an unnecessary save and restore of a callee >> saved register in the prologue and epilogue even though the reference >> of the callee saved register has been removed by the renaming pass. >> I am using the prologue/epilogue patterns instead of the target macros. > > Which version of gcc? I was under the impression that this > longstanding buglet was cleaned up by the dataflow work. >
I am doing a port in gcc 4.1.2. The register is actually replaced by register copy-propagation optimization pass. Here is the rtl dumps before .rnreg (the relevant portions) (insn/f 42 41 43 0 (set (mem:HI (reg/f:HI 12 R12) [0 S2 A16]) (reg:HI 4 R4)) -1 (nil) (expr_list:REG_DEAD (reg:HI 4 R4) (nil))) (note 43 42 9 0 NOTE_INSN_PROLOGUE_END) (note 9 43 14 0 NOTE_INSN_FUNCTION_BEG) (insn 14 9 37 0 (set (reg:HI 4 R4 [orig:26+2 ] [26]) (reg:HI 0 R0 [ pExtern ])) 1 {*movhi_internal} (insn_list:REG_DEP_ANTI 16 (nil)) (expr_list:REG_DEAD (reg:HI 0 R0 [ pExtern ]) (expr_list:REG_NO_CONFLICT (reg/v:SI 0 R0 [orig:23 pExtern ] [23]) (nil)))) (insn 37 14 18 0 (set (reg:HI 8 R8) (const_int 42 [0x2a])) 1 {*movhi_internal} (nil) (nil)) (insn 18 37 38 0 (set (unspec:HI [ (reg:HI 8 R8) ] 2) (unspec_volatile:HI [ (reg:HI 4 R4 [orig:26+2 ] [26]) ] 6)) 6 {out} (insn_list:REG_DEP_TRUE 17 (insn_list:REG_DEP_ANTI 14 (insn_list:REG_DEP_TRUE 7 (insn_list:REG_DEP_TRUE 6 (nil))))) (expr_list:REG_DEAD (reg:HI 8 R8) (expr_list:REG_DEAD (reg:HI 4 R4 [orig:26+2 ] [26]) (nil)))) And this is the after the optimization pass insn 18: replaced reg 4 with 0 ..... (insn/f 42 41 43 0 (set (mem:HI (reg/f:HI 12 R12) [0 S2 A16]) (reg:HI 4 R4)) 1 {*movhi_internal} (nil) (expr_list:REG_DEAD (reg:HI 4 R4) (nil))) (note 43 42 9 0 NOTE_INSN_PROLOGUE_END) (note 9 43 37 0 NOTE_INSN_FUNCTION_BEG) (insn 37 9 18 0 (set (reg:HI 8 R8) (const_int 42 [0x2a])) 1 {*movhi_internal} (nil) (nil)) (insn 18 37 38 0 (set (unspec:HI [ (reg:HI 8 R8) ] 2) (unspec_volatile:HI [ (reg:HI 0 R0 [orig:26+2 ] [26]) ] 6)) 6 {out} (insn_list:REG_DEP_TRUE 17 (insn_list:REG_DEP_ANTI 14 (insn_list:REG_DEP_TRUE 7 (insn_list:REG_DEP_TRUE 6 (nil))))) (expr_list:REG_DEAD (reg:HI 8 R8) (expr_list:REG_DEAD (reg:HI 0 R0 [orig:26+2 ] [26]) (nil)))) >> So is the rename pass allowed to rename a callee saved register? Where >> might this going wrong? > > If this is the buglet I'm thinking of, the resulting code does work, > despite being suboptimal. It just does an unnecessary save and > restore. The resulting code is proper except for the unnecessary save and > restore. > > Ian >