Fix PR46932: Block auto increment on frame pointer

Block auto increment on frame pointer references.  This is never
beneficial since the SFP expands into SP+C or FP+C during register
allocation.  The generated code for the testcase is now as expected:

	str	x30, [sp, -32]!
	strb	w0, [sp, 31]
	add	x0, sp, 31
	bl	foo3
	ldr	x30, [sp], 32
	ret

    gcc/
	PR middle-end/46932
	* auto-inc-dec.c (parse_add_or_inc): Block autoinc on sfp.

    gcc/testsuite/
	PR middle-end/46932
	* gcc.dg/pr46932.c: New testcase.

From-SVN: r250564
This commit is contained in:
Wilco Dijkstra 2017-07-26 10:49:17 +00:00 committed by Wilco Dijkstra
parent 108c3c88d7
commit e17114487d
4 changed files with 29 additions and 0 deletions

View File

@ -1,3 +1,8 @@
2017-07-26 Wilco Dijkstra <wdijkstr@arm.com>
PR middle-end/46932
* auto-inc-dec.c (parse_add_or_inc): Block autoinc on sfp.
2017-07-26 Martin Liska <mliska@suse.cz>
PR sanitize/81186

View File

@ -769,6 +769,12 @@ parse_add_or_inc (rtx_insn *insn, bool before_mem)
inc_insn.pat = pat;
inc_insn.reg_res = SET_DEST (pat);
inc_insn.reg0 = XEXP (SET_SRC (pat), 0);
/* Block any auto increment of the frame pointer since it expands into
an addition and cannot be removed by copy propagation. */
if (inc_insn.reg0 == frame_pointer_rtx)
return false;
if (rtx_equal_p (inc_insn.reg_res, inc_insn.reg0))
inc_insn.form = before_mem ? FORM_PRE_INC : FORM_POST_INC;
else

View File

@ -1,3 +1,8 @@
2017-07-26 Wilco Dijkstra <wdijkstr@arm.com>
PR middle-end/46932
* gcc.dg/pr46932.c: New testcase.
2017-07-26 Martin Liska <mliska@suse.cz>
PR sanitize/81186

View File

@ -0,0 +1,13 @@
/* { dg-options "-O2 -fdump-rtl-auto_inc_dec" } */
/* Check that accesses based on the frame pointer do not
use auto increment. */
extern void foo(char*);
void t01(char t)
{
char c = t;
foo(&c);
}
/* { dg-final { scan-rtl-dump-not "success" "auto_inc_dec" } } */