AVR: target/116295 - Fix unrecognizable insn with __flash read.

Some loads from non-generic address-spaces are performed by
libgcc calls, and they don't have a POST_INC form.  Don't consider
such insns when running -mfuse-add.

     PR target/116295
gcc/
	* config/avr/avr.cc (Mem_Insn::Mem_Insn): Don't consider MEMs
	that are avr_mem_memx_p or avr_load_libgcc_p.

gcc/testsuite/
	* gcc.target/avr/torture/pr116295.c: New test.
This commit is contained in:
Georg-Johann Lay 2024-08-08 18:31:16 +02:00
parent f6a41ebb5b
commit c4d3dba253
2 changed files with 26 additions and 0 deletions

View file

@ -2121,6 +2121,10 @@ avr_pass_fuse_add::Mem_Insn::Mem_Insn (rtx_insn *insn)
else
return;
if (avr_mem_memx_p (mem)
|| avr_load_libgcc_p (mem))
return;
addr = XEXP (mem, 0);
addr_code = GET_CODE (addr);

View file

@ -0,0 +1,22 @@
/* { dg-do link } */
/* { dg-additional-options "-std=gnu99" } */
#ifdef __FLASH
long val;
__attribute__((used))
const __flash long*
load4_flash (const __flash long *p)
{
val += *p++;
val += *p++;
return p;
}
#endif
int main (void)
{
return 0;
}