i386: Avoid stack realignment if possible

Programming / Compilers / GCC - hjl [138bc75d-0d04-0410-961f-82ee72b054a4] - 5 September 2017 12:39 EDT

ix86_finalize_stack_frame_flags has been extended to eliminate frame pointer when the new stack frame isn't needed with and without-maccumulate-outgoing-args as well as -fomit-frame-pointer. Since stack access with larger alignment may be optimized out, to decide if stack realignment is needed, we need to not only check for stack frame access, but also verify the alignment of stack frame access. Since alignment of memory access via arg_pointer is set up by caller, not by callee, we should find the maximum stack alignment from the stack frame access instructions via stack pointer and frame pointrer to avoid stack realignment when stack alignment needed is less than incoming stack boundary.

gcc/

PR target/59501 PR target/81624 PR target/81769
- config/i386/i386.c (ix86_finalize_stack_frame_flags): Don't realign stack if stack alignment needed is less than incoming stack boundary.

gcc/testsuite/

PR target/59501 PR target/81624 PR target/81769
- gcc.target/i386/pr59501-4a.c: Remove xfail.
- gcc.target/i386/pr81769-1a.c: New test.
- gcc.target/i386/pr81769-1b.c: Likewise.
- gcc.target/i386/pr81769-2.c: Likewise.

d960aad i386: Avoid stack realignment if possible
gcc/ChangeLog | 9 ++
gcc/config/i386/i386.c | 143 ++++++++++++++++++-----------
gcc/testsuite/ChangeLog | 10 ++
gcc/testsuite/gcc.target/i386/pr59501-4a.c | 2 +-
gcc/testsuite/gcc.target/i386/pr81769-1a.c | 21 +++++
gcc/testsuite/gcc.target/i386/pr81769-1b.c | 7 ++
gcc/testsuite/gcc.target/i386/pr81769-2.c | 21 +++++
7 files changed, 157 insertions(+), 56 deletions(-)

Upstream: gcc.gnu.org


  • Share