libcall problem during new unroller merge
Zdenek Dvorak
rakdver@atrey.karlin.mff.cuni.cz
Thu Feb 6 13:59:00 GMT 2003
Hello,
during merging new loop unroller, I have encountered the following
problem (masked on rtlopt branch by other pass):
Consider loop in that strcmp is called; it is translated into rtl as
(insn 542 541 543 (nil) (set (reg:SI 236)
(mem/s/u:SI (plus:SI (reg:SI 235)
(reg:SI 231)) [9 <variable>.name+0 S4 A32])) -1 (nil)
(nil))
(insn 543 542 544 (nil) (set (mem/f:SI (plus:SI (reg/f:SI 56 virtual-outgoing-args)
(const_int 4 [0x4])) [0 S4 A32])
(reg:SI 236)) -1 (nil)
(insn_list:REG_LIBCALL 547 (nil)))
(insn 544 543 545 (nil) (set (reg:SI 237)
(mem/f:SI (symbol_ref:SI ("ix86_cpu_string")) [9 ix86_cpu_string+0 S4 A32])) -1 (nil)
(nil))
(insn 545 544 546 (nil) (set (mem/f:SI (reg/f:SI 56 virtual-outgoing-args) [0 S4 A32])
(reg:SI 237)) -1 (nil)
(nil))
(call_insn/u 546 545 547 (nil) (set (reg:SI 0 eax)
(call (mem:QI (symbol_ref:SI ("strcmp")) [0 S1 A8])
(const_int 8 [0x8]))) -1 (nil)
(expr_list:REG_EH_REGION (const_int -1 [0xffffffff])
(nil))
(expr_list (use (mem:BLK (scratch) [0 A8]))
(nil)))
(insn 547 546 548 (nil) (set (reg:SI 238)
(reg:SI 0 eax)) -1 (nil)
(insn_list:REG_RETVAL 543 (expr_list:REG_EQUAL (expr_list (use (mem:BLK (scratch) [0 A8]))
(expr_list (symbol_ref:SI ("strcmp"))
(expr_list (mem/f:SI (symbol_ref:SI ("ix86_cpu_string")) [9 ix86_cpu_string+0 S4 A32])
(expr_list (mem/s/u:SI (plus:SI (reg:SI 235)
(reg:SI 231)) [9 <variable>.name+0 S4 A32])
(nil)))))
(nil))))
now first cse pass transforms insn 542 into
(insn 542 541 543 71 0x402e1108 (set (reg:SI 236 [ <variable>.name ])
(mem/s/u:SI (plus:SI (reg:SI 235)
(symbol_ref:SI ("processor_alias_table.2"))) [9 <variable>.name+0 S4 A32])) 38 {*movsi_1} (nil)
(nil))
Reference in REG_EQUAL is not updated; set of reg. 231 disappears.
Similarily, reg. 235 disappears in global copy propagation (in
jump bypassing pass), being replaced by other register; again,
reference in REG_EQUAL is not updated.
REG_RETVAL note now refers only to non-existent registers, and unroller
creates 4 consecutive clones of this block.
Finally, second cse pass uses these notes to replace 3 of copies of insn
547 by
(insn 1870 1869 1871 150 0x4016bfa4 (set (reg:SI 238)
(reg:SI 238)) 38 {*movsi_1} (nil)
(expr_list:REG_EQUAL (expr_list (use (mem:BLK (scratch) [0 A8]))
(expr_list (symbol_ref:SI ("strcmp"))
(expr_list (mem/f:SI (symbol_ref:SI ("ix86_cpu_string")) [9 ix86_cpu_string+0 S4 A32])
(expr_list (mem/s/u:SI (plus:SI (reg:SI 235)
(reg/f:SI 231)) [9 <variable>.name+0 S4 A32])
(nil)))))
(insn_list:REG_RETVAL 1866 (nil))))
causing misscompilation. In my opinion, the fact that REG_RETVAL note
refers to completely bogus expression is wrong; but I am not sure where
is the right place to fix it.
Zdenek
More information about the Gcc
mailing list