https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122992
Bug ID: 122992
Summary: speed up loops with TEST_HARD_REG_BIT using
EXECUTE_IF_SET_IN_HARD_REG_SET
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Keywords: easyhack
Severity: normal
Priority: P3
Component: rtl-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: aoliva at gcc dot gnu.org
Target Milestone: ---
Loops of the form
for (int <i> = 0; <i> < FIRST_PSEUDO_REGISTER; <i>++)
if (TEST_HARD_REG_BIT (<set>, <i>))
<body that doesn't change i or set>
can be made more efficient when expressing <set> doesn't involve <i> by
rewriting them as
hard_reg_set_iterator hrsi; [...]
EXECUTE_IF_SET_IN_HARD_REG_SET (<set>, 0, <i>, hrsi)
<body that doesn't change i or set>
caller-save.cc:setup_save_areas has one such loop. There are more throughout
the source tree. git grep TEST_HARD_REG_BIT will list many candidates, but
also many false positives, that are not part of loops, that use a different
upper bound, that test different sets in each loop iteration, or that otherwise
fail to match this pattern.
Improving any of these would be a useful contribution to gcc, that wouldn't be
hard for a beginner to make.
Even finding those that could be changed or not, and either improving those
that can or noting here those that can't, would be useful. There are some 500
hits for TEST_HARD_REG_BIT within gcc/ in over 80 files.