diff --git a/gcc/testsuite/gcc.target/mips/fho-1.c b/gcc/testsuite/gcc.target/mips/fho-1.c new file mode 100644 index 0000000..e373da4 --- /dev/null +++ b/gcc/testsuite/gcc.target/mips/fho-1.c @@ -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 } } */ diff --git a/gcc/testsuite/gcc.target/mips/fho-2.c b/gcc/testsuite/gcc.target/mips/fho-2.c new file mode 100644 index 0000000..d3599b8 --- /dev/null +++ b/gcc/testsuite/gcc.target/mips/fho-2.c @@ -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); +} diff --git a/gcc/testsuite/gcc.target/mips/mips.exp b/gcc/testsuite/gcc.target/mips/mips.exp index b3617e4..6e6450e 100644 --- a/gcc/testsuite/gcc.target/mips/mips.exp +++ b/gcc/testsuite/gcc.target/mips/mips.exp @@ -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"