On 25-04-14 15:22, Richard Sandiford wrote: > Tom de Vries 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. > Richard, Done. > 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. > Done. >> 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). I've reduced the amount of skips a bit, and added a comment why they are skipped. > >> +/* 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. > Done, I think, I'm not 100% sure I understood what you wanted me to do here. build and reg-tested on MIPS. OK for trunk? Thanks, - Tom