AVR: Run pass avr-fuse-add a second time after pass_cprop_hardreg.

gcc/
	* config/avr/avr-passes.cc (avr_pass_fuse_add) <clone>: Override.
	* config/avr/avr-passes.def (avr_pass_fuse_add): Run again
	after pass_cprop_hardreg.
This commit is contained in:
Georg-Johann Lay 2024-08-30 19:38:30 +02:00
parent 60fc5501dd
commit df89afbb77
2 changed files with 28 additions and 0 deletions

View file

@ -1026,6 +1026,13 @@ public:
this->name = name;
}
// Cloning is required because we are running one instance of the pass
// before peephole2. and a second one after cprop_hardreg.
opt_pass * clone () final override
{
return make_avr_pass_fuse_add (m_ctxt);
}
bool gate (function *) final override
{
return optimize && avr_fuse_add > 0;

View file

@ -26,6 +26,27 @@
INSERT_PASS_BEFORE (pass_peephole2, 1, avr_pass_fuse_add);
/* There are cases where avr-fuse-add doesn't find POST_INC cases because
the RTL code at that time is too long-winded, and moves registers back and
forth (which seems to be the same reason for why pass auto_inc_dec cannot
find POST_INC, either). Some of that long-windedness is cleaned up very
late in pass cprop_hardreg, which opens up new opportunities to find post
increments. An example is the following function from AVR-LibC's qsort:
void swapfunc (char *a, char *b, int n)
{
do
{
char tmp = *a;
*a++ = *b;
*b++ = tmp;
} while (--n > 0);
}
Hence, run avr-fuse-add twice; the second time after cprop_hardreg. */
INSERT_PASS_AFTER (pass_cprop_hardreg, 1, avr_pass_fuse_add);
/* An analysis pass that runs prior to prologue / epilogue generation.
Computes cfun->machine->gasisr.maybe which is used in prologue and
epilogue generation provided -mgas-isr-prologues is on. */