This is the mail archive of the gcc-patches@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]

[PATCH] Fix libcall_dead_p (PR middle-end/19551)


Hi!

libcall_dead_p is too optimistic in its decisions what libcalls are
actually dead.  The attached testcase shows several things that it gets
wrong on at least i386, x86_64, ia64, ppc and ppc64 (but not on e.g.
s390/s390x).
E.g. in:
(call_insn/u 17 16 18 0 (set (reg:SC 0 ax)
        (call (mem:QI (symbol_ref:SI ("foo_float") [flags 0x3] <function_decl 0x2a97cb7750 foo_float>) [0 S1 A8])
            (const_int 4 [0x4]))) -1 (nil)
    (expr_list:REG_EH_REGION (const_int -1 [0xffffffffffffffff])
        (nil))
    (expr_list (use (mem:BLK (scratch) [0 A8]))
        (nil)))

(insn 18 17 19 0 (set (reg:SF 63)
        (reg:SF 0 ax)) 91 {*movsf_1_nointerunit} (nil)
    (nil))

(insn 19 18 25 0 (set (reg:SF 64 [+4 ])
        (reg:SF 1 dx [+4 ])) 91 {*movsf_1_nointerunit} (nil)
    (insn_list:REG_RETVAL 16 (nil)))

(insn 25 19 27 0 (set (mem:SF (reg/v/f:SI 58 [ x ]) [3 S4 A32])
        (reg:SF 63)) 91 {*movsf_1_nointerunit} (nil)
    (nil))
;; End of basic block 0, registers live:
 (nil)

(note 27 25 0 NOTE_INSN_FUNCTION_END)
insn 19 is dead and ax is not live at the end either, so libcall_dead_p
decides the whole libcall is dead, while reg 63 is actually live.
The attached patch seems to fix this.
On 3.4 branch it causes some really dead libcalls not to be deleted
on at least i386, x86_64 and ia64 while they used to be previously
optimized out, but it seems to do that only for a subset of the cases
that it got wrong if the libcalls are actually used and it deleted
them anyway.  Particularly for CQI, CHI and on 64-bit CSI returns,
where the libcall's value is stored into memory and then read from
it again.  On HEAD this shouldn't be a problem, as tree-SSA kills
the dead calls far earlier.

Ok to commit? HEAD and 3.4?

	Jakub

Attachment: PR19551-HEAD
Description: Text document

Attachment: PR19551-3.4
Description: Text document


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