diff options
author | Jakub Jelinek <jakub@redhat.com> | 2021-04-03 10:07:09 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2021-04-22 16:53:43 +0200 |
commit | e1ef85b4f29e04e97f2ac0998bfd62bac50428b9 (patch) | |
tree | 3f0e315a331ebefd227fe8576eb63c9293833cda /gcc/dse.c | |
parent | 718c32a39895ea12ff79f05d6001d7401e6e7e11 (diff) | |
download | gcc-e1ef85b4f29e04e97f2ac0998bfd62bac50428b9.zip gcc-e1ef85b4f29e04e97f2ac0998bfd62bac50428b9.tar.gz gcc-e1ef85b4f29e04e97f2ac0998bfd62bac50428b9.tar.bz2 |
dse: Fix up hard reg conflict checking in replace_read [PR99863]
Since PR37922 fix RTL DSE has hard register conflict checking
in replace_read, so that if the replacement sequence sets (or typically just
clobbers) some hard register (usually condition codes) we verify that
hard register is not live.
Unfortunately, it compares the hard reg set clobbered/set by the sequence
(regs_set) against the currently live hard register set, but it then
emits the insn sequence not at the current insn position, but before
store_insn->insn.
So, we should not compare against the current live hard register set,
but against the hard register live set at the point of the store insn.
Fortunately, we already have that remembered in store_insn->fixed_regs_live.
In addition to bootstrapping/regtesting this patch on x86_64-linux and
i686-linux, I've also added statistics gathering and it seems the only
place where we end up rejecting the replace_read is the newly added
testcase (the PR37922 is no longer effective at that) and fixed_regs_live
has been always non-NULL at the if (store_insn->fixed_regs_live) spot.
Rather than having there an assert, I chose to just keep regs_set
as is, which means in that hypothetical case where fixed_regs_live wouldn't
be computed for some store we'd still accept sequences that don't
clobber/set any hard registers and just punt on those that clobber/set
those.
2021-04-03 Jakub Jelinek <jakub@redhat.com>
PR rtl-optimization/99863
* dse.c (replace_read): Drop regs_live argument. Instead of
regs_live, use store_insn->fixed_regs_live if non-NULL,
otherwise punt if insns sequence clobbers or sets any hard
registers.
* gcc.target/i386/pr99863.c: New test.
(cherry picked from commit 7a2f91d413eb7a3eb0ba52c7ac9618a35addd12a)
Diffstat (limited to 'gcc/dse.c')
-rw-r--r-- | gcc/dse.c | 11 |
1 files changed, 5 insertions, 6 deletions
@@ -1922,8 +1922,7 @@ get_stored_val (store_info *store_info, machine_mode read_mode, static bool replace_read (store_info *store_info, insn_info_t store_insn, - read_info_t read_info, insn_info_t read_insn, rtx *loc, - bitmap regs_live) + read_info_t read_info, insn_info_t read_insn, rtx *loc) { machine_mode store_mode = GET_MODE (store_info->mem); machine_mode read_mode = GET_MODE (read_info->mem); @@ -1978,7 +1977,8 @@ replace_read (store_info *store_info, insn_info_t store_insn, for (this_insn = insns; this_insn != NULL_RTX; this_insn = NEXT_INSN (this_insn)) note_stores (PATTERN (this_insn), look_for_hardregs, regs_set); - bitmap_and_into (regs_set, regs_live); + if (store_insn->fixed_regs_live) + bitmap_and_into (regs_set, store_insn->fixed_regs_live); if (!bitmap_empty_p (regs_set)) { if (dump_file && (dump_flags & TDF_DETAILS)) @@ -2185,7 +2185,7 @@ check_mem_read_rtx (rtx *loc, bb_info_t bb_info) offset - store_info->offset, width) && replace_read (store_info, i_ptr, read_info, - insn_info, loc, bb_info->regs_live)) + insn_info, loc)) return; /* The bases are the same, just see if the offsets @@ -2251,8 +2251,7 @@ check_mem_read_rtx (rtx *loc, bb_info_t bb_info) store_info->width) && all_positions_needed_p (store_info, offset - store_info->offset, width) - && replace_read (store_info, i_ptr, read_info, insn_info, loc, - bb_info->regs_live)) + && replace_read (store_info, i_ptr, read_info, insn_info, loc)) return; remove = canon_true_dependence (store_info->mem, |