From: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
To: GCC Patches <gcc-patches@gcc.gnu.org>
Cc: nd <nd@arm.com>
Subject: [PATCH] Fix PR46932: Block auto increment on frame pointer
Date: Thu, 20 Jul 2017 14:49:00 -0000 [thread overview]
Message-ID: <AM5PR0802MB2610C93E52AAFEFD3A1DA5B283A70@AM5PR0802MB2610.eurprd08.prod.outlook.com> (raw)
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
On SPEC2017 codesize improves uniformly across the board.
ChangeLog:
2017-07-20 Wilco Dijkstra <wdijkstr@arm.com>
PR middle-end/46932
* auto-inc-dec.c (parse_add_or_inc): Block autoinc on sfp.
gcc/testsuite/
* gcc.dg/pr46932.c: New testcase.
--
diff --git a/gcc/auto-inc-dec.c b/gcc/auto-inc-dec.c
index 91fa5cf0bbe04b8a2c2c2b9209d245a327de0ffd..db1bd5bba2cee9fbf24d6d522505ac292688aab9 100644
--- a/gcc/auto-inc-dec.c
+++ b/gcc/auto-inc-dec.c
@@ -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
diff --git a/gcc/testsuite/gcc.dg/pr46932.c b/gcc/testsuite/gcc.dg/pr46932.c
new file mode 100644
index 0000000000000000000000000000000000000000..b96febcc095fbec2cc4e02d1155871220d17cc99
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr46932.c
@@ -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" } } */
next reply other threads:[~2017-07-20 14:49 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-20 14:49 Wilco Dijkstra [this message]
2017-07-25 20:42 ` Jeff Law
2017-07-25 21:25 ` Wilco Dijkstra
2017-07-25 22:29 ` Jeff Law
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=AM5PR0802MB2610C93E52AAFEFD3A1DA5B283A70@AM5PR0802MB2610.eurprd08.prod.outlook.com \
--to=wilco.dijkstra@arm.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=nd@arm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).