https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81624
--- Comment #3 from hjl at gcc dot gnu.org <hjl at gcc dot gnu.org> --- Author: hjl Date: Tue Sep 5 16:39:24 2017 New Revision: 251718 URL: https://gcc.gnu.org/viewcvs?rev=251718&root=gcc&view=rev Log: i386: Avoid stack realignment if possible 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. Added: trunk/gcc/testsuite/gcc.target/i386/pr81769-1a.c trunk/gcc/testsuite/gcc.target/i386/pr81769-1b.c trunk/gcc/testsuite/gcc.target/i386/pr81769-2.c Modified: trunk/gcc/ChangeLog trunk/gcc/config/i386/i386.c trunk/gcc/testsuite/ChangeLog trunk/gcc/testsuite/gcc.target/i386/pr59501-4a.c