This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: -fuse-caller-save - Enable for MIPS
- From: Richard Sandiford <rdsandiford at googlemail dot com>
- To: Tom de Vries <Tom_deVries at mentor dot com>
- Cc: "gcc-patches\ at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 25 Apr 2014 14:22:45 +0100
- Subject: Re: -fuse-caller-save - Enable for MIPS
- Authentication-results: sourceware.org; auth=none
- References: <534ED7BC dot 50300 at mentor dot com> <534FF0F9 dot 60404 at redhat dot com> <87lhv4ug7f dot fsf at sandifor-thinkpad dot stglab dot manchester dot uk dot ibm dot com> <53500628 dot 2090802 at redhat dot com> <5356853D dot 8050905 at mentor dot com> <535A5A8F dot 30901 at mentor dot com>
Tom de Vries <Tom_deVries@mentor.com> writes:
> diff --git a/gcc/config/mips/mips.c b/gcc/config/mips/mips.c
> index 45256e9..b61cd44 100644
> --- a/gcc/config/mips/mips.c
> +++ b/gcc/config/mips/mips.c
> @@ -7027,11 +7027,17 @@ mips_expand_call (enum mips_call_type type, rtx result, rtx addr,
> {
> rtx orig_addr, pattern, insn;
> int fp_code;
> + rtx post_call_tmp_reg = gen_rtx_REG (word_mode, POST_CALL_TMP_REG);
>
> fp_code = aux == 0 ? 0 : (int) GET_MODE (aux);
> insn = mips16_build_call_stub (result, &addr, args_size, fp_code);
> if (insn)
> {
> + if (TARGET_EXPLICIT_RELOCS
> + && TARGET_CALL_CLOBBERED_GP
> + && !find_reg_note (insn, REG_NORETURN, 0))
> + clobber_reg (&CALL_INSN_FUNCTION_USAGE (insn), post_call_tmp_reg);
> +
I think this condition should go in mips_emit_call_insn instead,
so that we don't have 4 instances of it. untyped_call could then
use mips_expand_call as well.
Until now there was no real downside to using $6 for non-MIPS16 code.
Now that there is, it would probably be worth making it:
+#define POST_CALL_TMP_REG \
(TARGET_MIPS16 ? GP_ARG_FIRST + 2 : PIC_OFFSET_TABLE_REGNUM)
and only adding the clobber for MIPS16.
> diff --git a/gcc/testsuite/gcc.target/mips/fuse-caller-save.c b/gcc/testsuite/gcc.target/mips/fuse-caller-save.c
> new file mode 100644
> index 0000000..1fd6c7d
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/mips/fuse-caller-save.c
> @@ -0,0 +1,30 @@
> +/* { dg-do compile } */
> +/* { dg-options "-fuse-caller-save" } */
> +/* { dg-skip-if "" { *-*-* } { "*" } { "-Os" } } */
I might have asked this before, sorry, but why this skip? Please add a brief
comment (in the string, if short enough).
> +/* Testing -fuse-caller-save optimization option. */
> +
> +static int __attribute__((noinline)) NOCOMPRESSION
> +bar (int x)
> +{
> + return x + 3;
> +}
> +
> +int __attribute__((noinline)) NOCOMPRESSION
> +foo (int y)
> +{
> + return y + bar (y);
> +}
> +
> +int NOCOMPRESSION
> +main (void)
> +{
> + return !(foo (5) == 13);
> +}
> +
> +/* Check that there are only 2 stack-saves: r31 in main and foo. */
> +
> +/* Check that there only 2 sw/sd. */
> +/* { dg-final { scan-assembler-times "(?n)s\[wd\]\t\\\$.*,.*\\(\\\$sp\\)" 2 } } */
> +
> +/* Check that the first caller-save register is unused. */
> +/* { dg-final { scan-assembler-not "\\\$16" } } */
It'd be good to avoid NOCOMPRESSION because the only case that really
needs the temporary register is MIPS16. Please try putting the test
in a header file and reusing it for three tests, one each of MIPS16,
microMIPS and uncompressed.
Thanks,
Richard