Bug 81813 - Inefficient stack pointer adjustment
Summary: Inefficient stack pointer adjustment
Status: UNCONFIRMED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 7.1.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: missed-optimization
Depends on:
Blocks:
 
Reported: 2017-08-11 02:31 UTC by Josh Poimboeuf
Modified: 2017-08-15 10:18 UTC (History)
1 user (show)

See Also:
Host:
Target: x86_64-*-*
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
fs_pin.i (129.27 KB, text/plain)
2017-08-11 02:31 UTC, Josh Poimboeuf
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Josh Poimboeuf 2017-08-11 02:31:32 UTC
Created attachment 41968 [details]
fs_pin.i

With GCC 7.1, the kernel's object code static analysis tool (objtool) found this unusual method of adjusting the stack pointer in the kernel:

   2cc:   48 8d 4c 24 08          lea    0x8(%rsp),%rcx
   2d1:   48 89 cc                mov    %rcx,%rsp

The value in %rcx was never used afterwards.  It would be faster and more straightforward to just add 8 to %rsp.

To recreate:

  gcc -mno-sse -mpreferred-stack-boundary=3 -O2 -c -o fs_pin.o fs_pin.i
Comment 1 Richard Biener 2017-08-15 10:18:20 UTC
Interesting ;)  A peephole might help.