]> git.ipfire.org Git - thirdparty/gcc.git/commit
Correct x86: Call ix86_access_stack_p only for larger alignment
authorH.J. Lu <hjl.tools@gmail.com>
Fri, 3 Apr 2026 07:55:17 +0000 (15:55 +0800)
committerH.J. Lu <hjl.tools@gmail.com>
Tue, 7 Apr 2026 21:22:57 +0000 (05:22 +0800)
commit7b39d7b3b84d4d098b51bbdbd15e6ddea6bf99db
treeafc263a66a7f6542eda6feb507219da2510cfd78
parentc8a84242e4bf53db8ab5c10a508a13e637953556
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>
gcc/config/i386/i386.cc
gcc/testsuite/gcc.target/i386/pr124759.c [new file with mode: 0644]