new file mode 100644
@@ -0,0 +1,36 @@
+/* { dg-do compile } */
+/* { dg-skip-if "code quality test" { *-*-* } { "-O0" } { "" } } */
+/* { dg-options "-mabi=32 -mframe-header-opt -fdump-rtl-mach" } */
+/* Testing -mframe-header-opt optimization option. */
+
+NOCOMPRESSION int __attribute__((noinline))
+B (int x)
+{
+ return x + 3;
+}
+
+/* We are sure that B is not using its incoming stack frame so we can skip
+ its allocation. */
+NOCOMPRESSION int __attribute__((noinline))
+A (int x)
+{
+ return B (x) + 2;
+}
+
+NOCOMPRESSION int
+main (void)
+{
+ int a;
+ void *volatile sp1, *volatile sp2;
+ register void *sp asm ("$sp");
+ sp1 = sp;
+ a = A (5);
+ sp2 = sp;
+ return !(a == 10 && sp1 == sp2);
+}
+
+/* { dg-final { scan-rtl-dump "Frame size reduced by frame header optimization" "mach" } } */
+
+/* For enabled targets, test that only one stack allocation is present, the one
+ in main. The one in A should have been removed by -mframe-header-opt. */
+/* { dg-final { scan-assembler-times "addiu\t\\\$sp,\\\$sp,-" 1 } } */
new file mode 100644
@@ -0,0 +1,29 @@
+/* { dg-do run } */
+/* { dg-options "-mabi=32 -mframe-header-opt" } */
+/* Testing -mframe-header-opt optimization option. */
+
+NOCOMPRESSION int __attribute__((noinline))
+B (int x)
+{
+ return x + 3;
+}
+
+/* We are sure that B is not using its incoming stack frame so we can skip
+ its allocation. */
+NOCOMPRESSION int __attribute__((noinline))
+A (int x)
+{
+ return B (x) + 2;
+}
+
+NOCOMPRESSION int
+main (void)
+{
+ int a;
+ void *volatile sp1, *volatile sp2;
+ register void *sp asm ("$sp");
+ sp1 = sp;
+ a = A (5);
+ sp2 = sp;
+ return !(a == 10 && sp1 == sp2);
+}
@@ -237,6 +237,7 @@ set mips_option_groups {
fpu "-m(double|single)-float"
forbid_cpu "forbid_cpu=.*"
fp "-mfp(32|xx|64)"
+ frame_header_opt "-mframe-header-opt|-mno-frame-header-opt"
gp "-mgp(32|64)"
long "-mlong(32|64)"
micromips "-mmicromips|-mno-micromips"