]> git.ipfire.org Git - thirdparty/gcc.git/commit
resource.cc: Replace calls to find_basic_block with cfgrtl BLOCK_FOR_INSN
authorHans-Peter Nilsson <hp@axis.com>
Tue, 28 May 2024 21:16:48 +0000 (23:16 +0200)
committerHans-Peter Nilsson <hp@bitrange.com>
Tue, 28 May 2024 21:16:48 +0000 (23:16 +0200)
commit933ab59c59bdc1ac9e3ca3a56527836564e1821b
treeeea7bd6fa76d6b5a924e0015e9788e125fadf9be
parent84b4ed45ea81ed5c4fb656a17846b26071c23e7d
resource.cc: Replace calls to find_basic_block with cfgrtl BLOCK_FOR_INSN

...and call compute_bb_for_insn in init_resource_info and
free_bb_for_insn in free_resource_info.

I put a gcc_unreachable in that else-clause for a failing
find_basic_block in mark_target_live_regs after the comment that says:

    /* We didn't find the start of a basic block.  Assume everything
       in use.  This should happen only extremely rarely.  */
    SET_HARD_REG_SET (res->regs);

and found that it fails not extremely rarely but extremely early in
the build (compiling libgcc).

That kind of pessimization leads to suboptimal delay-slot-filling.
Instead, do like many machine_dependent_reorg passes and call
compute_bb_for_insn as part of resource.cc initialization.

After this patch, there's a whole "if (b != -1)" conditional that's
dominated by a gcc_assert (b != -1).  I separated that, as it's a NFC
whitespace patch that hampers patch readability.

Altogether this improved coremark performance for CRIS at -O2
-march=v10 by 0.36%.

* resource.cc: Include cfgrtl.h.  Use BLOCK_FOR_INSN (insn)->index
instead of calling find_basic_block (insn).  Assert for not -1.
(find_basic_block): Remove function.
(init_resource_info): Call compute_bb_for_insn.
(free_resource_info): Call free_bb_for_insn.
gcc/resource.cc