diff mbox series

[avr,applied] Fix target/116295 unrecognizable insn

Message ID 0acb4e37-1a2f-44b5-a1a4-911f17a8dc23@gjlay.de
State New
Headers show
Series [avr,applied] Fix target/116295 unrecognizable insn | expand

Commit Message

Georg-Johann Lay Aug. 8, 2024, 4:59 p.m. UTC
Applied this fix to trunk and v14 branch.

Johann

--

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.
diff mbox series

Patch

diff --git a/gcc/config/avr/avr.cc b/gcc/config/avr/avr.cc
index 0b3fd7a36d0..5cfd67a8e74 100644
--- a/gcc/config/avr/avr.cc
+++ b/gcc/config/avr/avr.cc
@@ -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);
 
diff --git a/gcc/testsuite/gcc.target/avr/torture/pr116295.c b/gcc/testsuite/gcc.target/avr/torture/pr116295.c
new file mode 100644
index 00000000000..0b3d380ff14
--- /dev/null
+++ b/gcc/testsuite/gcc.target/avr/torture/pr116295.c
@@ -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;
+}