https://gcc.gnu.org/g:552476a97b55ff86d95cb6ec23a93bb54f8eee18

commit r17-2075-g552476a97b55ff86d95cb6ec23a93bb54f8eee18
Author: Oleg Endo <[email protected]>
Date:   Wed Jul 1 11:58:29 2026 +0900

    SH: Move and adjust testcase pr55212-c248.c
    
    gcc/testsuite/ChangeLog:
    
            PR target/55212
            * gcc.target/sh/pr55212-c248.c: Move to ..
            * gcc.target/sh/torture/pr55212-c248.c: .. here.  Skip it for -O0.

Diff:
---
 gcc/testsuite/gcc.target/sh/pr55212-c248.c         | 31 -----------------
 gcc/testsuite/gcc.target/sh/torture/pr55212-c248.c | 39 ++++++++++++++++++++++
 2 files changed, 39 insertions(+), 31 deletions(-)

diff --git a/gcc/testsuite/gcc.target/sh/pr55212-c248.c 
b/gcc/testsuite/gcc.target/sh/pr55212-c248.c
deleted file mode 100644
index 94fd6afaab3c..000000000000
--- a/gcc/testsuite/gcc.target/sh/pr55212-c248.c
+++ /dev/null
@@ -1,31 +0,0 @@
-/* { dg-do run }  */
-/* { dg-options "-O2 -m4 -mlra -ffixed-r7 -ffixed-r8 -ffixed-r9 -ffixed-r10 
-ffixed-r11 -ffixed-r12 -ffixed-r13" } */
-#include <stdlib.h>
-#include <string.h>
-
-typedef struct { int c[64]; } obj;
-obj obj0;
-obj obj1;
-
-void __attribute__ ((noinline))
-bar (int a, int b, int c, int d, obj *q)
-{
-  if (q->c[0] != 0x12345678 || q->c[1] != 0xdeadbeef) 
-    abort ();
-}
-
-void foo (obj *p)
-{
-  obj bobj;
-  bobj = *p;
-  bar (0, 0, 0, 0, &bobj);
-}
-
-int
-main ()
-{
-  obj0.c[0] = 0x12345678;
-  obj0.c[1] = 0xdeadbeef;
-  foo (&obj0);
-  exit (0);
-}
diff --git a/gcc/testsuite/gcc.target/sh/torture/pr55212-c248.c 
b/gcc/testsuite/gcc.target/sh/torture/pr55212-c248.c
new file mode 100644
index 000000000000..264f3952190d
--- /dev/null
+++ b/gcc/testsuite/gcc.target/sh/torture/pr55212-c248.c
@@ -0,0 +1,39 @@
+/* { dg-do run }  */
+/* { dg-options "-ffixed-r7 -ffixed-r8 -ffixed-r9 -ffixed-r10 -ffixed-r11 
-ffixed-r12 -ffixed-r13" }  */
+/* { dg-skip-if "over-constrained regs when not optimizting" { *-*-* } { "-O0" 
} { "" } }  */
+
+/* The 'block_lump_real_i4' insn that is emitted on SH4 will use up regs
+   r0~r6.  With r7~r13 being artificially fixed for this test case, there
+   is only r14 (frame pointer) and r15 (stack pointer) left.  When compiling
+   with -O0 the frame pointer is not eliminated and there are no free registers
+   remaining and it will ICE.  */
+
+#include <stdlib.h>
+#include <string.h>
+
+typedef struct { int c[64]; } obj;
+obj obj0;
+obj obj1;
+
+void __attribute__ ((noinline))
+bar (int a, int b, int c, int d, obj *q)
+{
+  if (q->c[0] != 0x12345678 || q->c[1] != 0xdeadbeef)
+    abort ();
+}
+
+void foo (obj *p)
+{
+  obj bobj;
+  bobj = *p;
+  bar (0, 0, 0, 0, &bobj);
+}
+
+int
+main ()
+{
+  obj0.c[0] = 0x12345678;
+  obj0.c[1] = 0xdeadbeef;
+  foo (&obj0);
+  exit (0);
+}

Reply via email to