This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug target/46932] Inefficient code sequence to access local variable
- From: "wilco at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 18 Jul 2017 13:39:04 +0000
- Subject: [Bug target/46932] Inefficient code sequence to access local variable
- Auto-submitted: auto-generated
- References: <bug-46932-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=46932
Wilco <wilco at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |wilco at gcc dot gnu.org
--- Comment #3 from Wilco <wilco at gcc dot gnu.org> ---
(In reply to Ramana Radhakrishnan from comment #1)
> Confirmed - still an issue with gcc trunk and same issue exists on aarch64
>
> ( -fomit-frame-pointer is a red herring).
>
> str x30, [sp, -32]!
> add x1, sp, 32
> strb w0, [x1, -1]!
> mov x0, x1
> bl foo
> ldr x30, [sp], 32
> ret
It's a bug in the auto_inc_dec phase. It shouldn't apply to constant addresses.
If I disable pre-decrement I get the expected:
str x30, [sp, -32]!
strb w0, [sp, 31]
add x0, sp, 31
bl foo3
ldr x30, [sp], 32
ret
Generally pre/post increment should be used when adjusting a pointer in a loop
- besides that there are very few cases where it improves code.