Commit e1711448 by Wilco Dijkstra Committed by Wilco Dijkstra

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
parent 108c3c88
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
......
......@@ -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
......
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
......
/* { 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" } } */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment