Correct x86: Call ix86_access_stack_p only for larger alignment
commit
f511bf93f947199a9f9099fee87b7052e5515fb9
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Sun Mar 29 14:30:28 2026 -0700
x86: Call ix86_access_stack_p only for larger alignment
has 2 issues:
1. It didn't exclude memory with SYMBOLIC_CONST when checking for stack
access.
2. It replaced:
HARD_REG_SET hard_stack_slot_access = stack_slot_access;
...
bool symbolic_const_load_p = false;
if (!TEST_HARD_REG_BIT (hard_stack_slot_access, regno))
...
symbolic_const_load_p = true;
...
if (!symbolic_const_load_p
|| ix86_access_stack_p...)
call ix86_update_stack_alignment.
with
if (ix86_need_alignment_p...
&& ix86_access_stack_p...)
call ix86_update_stack_alignment.
Since ix86_access_stack_p excludes registers on hard_stack_slot_access,
stack alignment isn't updated for registers on hard_stack_slot_access.
Instead, we should do
if (ix86_need_alignment_p...
&& (TEST_HARD_REG_BIT (hard_stack_slot_access, regno)
|| ix86_access_stack_p...))
call ix86_update_stack_alignment.
The compile times of PR target/124165 and PR target/124684 test are
unchanged.
if (ix86_need_alignment_p...
&& (TEST_HARD_REG_BIT (hard_stack_slot_access, regno)
|| ix86_access_stack_p...))
call ix86_update_stack_alignment.
gcc/
PR target/124759
PR target/124789
* config/i386/i386.cc (ix86_need_alignment_p_2): New function.
Exclude memory with SYMBOLIC_CONST.
(ix86_need_alignment_p_1): Call ix86_need_alignment_p_2.
(ix86_find_max_used_stack_alignment): Restore
hard_stack_slot_access handling.
gcc/testsuite/
PR target/124759
PR target/124789
* gcc.target/i386/pr124759.c: New test.
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>