Update x86: Call ix86_access_stack_p only for larger alignment
Commit Message
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
incorrectly uses GET_MODE_ALIGNMENT as memory alignment since memory
alignment can be different from mode alignment as in
(set (reg:OI 20 xmm0 [orig:112 s ] [112])
(mem/c:OI (plus:DI (reg/f:DI 7 sp)
(const_int -32 [0xffffffffffffffe0])) [3 s+0 S32 A128]))
MEM_ALIGN should be used instead.
* config/i386/i386.cc (ix86_need_alignment_p_1): Replace
GET_MODE_ALIGNMENT with MEM_ALIGN.
Comments
On Tue, 7 Apr 2026, H.J. Lu wrote:
> 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
>
> incorrectly uses GET_MODE_ALIGNMENT as memory alignment since memory
> alignment can be different from mode alignment as in
>
> (set (reg:OI 20 xmm0 [orig:112 s ] [112])
> (mem/c:OI (plus:DI (reg/f:DI 7 sp)
> (const_int -32 [0xffffffffffffffe0])) [3 s+0 S32 A128]))
>
> MEM_ALIGN should be used instead.
LGTM if you add the PR reference and the testcase (I assume the
other patch had both).
Thanks,
Richard.
> * config/i386/i386.cc (ix86_need_alignment_p_1): Replace
> GET_MODE_ALIGNMENT with MEM_ALIGN.
>
>
>
On Tue, Apr 7, 2026 at 6:57 PM Richard Biener <rguenther@suse.de> wrote:
>
> On Tue, 7 Apr 2026, H.J. Lu wrote:
>
> > 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
> >
> > incorrectly uses GET_MODE_ALIGNMENT as memory alignment since memory
> > alignment can be different from mode alignment as in
> >
> > (set (reg:OI 20 xmm0 [orig:112 s ] [112])
> > (mem/c:OI (plus:DI (reg/f:DI 7 sp)
> > (const_int -32 [0xffffffffffffffe0])) [3 s+0 S32 A128]))
> >
> > MEM_ALIGN should be used instead.
>
> LGTM if you add the PR reference and the testcase (I assume the
> other patch had both).
But this alone doesn't fix PR target/124759 and I couldn't find a testcase
which makes a difference.
> Thanks,
> Richard.
>
> > * config/i386/i386.cc (ix86_need_alignment_p_1): Replace
> > GET_MODE_ALIGNMENT with MEM_ALIGN.
> >
> >
> >
>
> --
> Richard Biener <rguenther@suse.de>
> SUSE Software Solutions Germany GmbH,
> Frankenstrasse 146, 90461 Nuernberg, Germany;
> GF: Jochen Jaser, Andrew McDonald, Werner Knoblich; (HRB 36809, AG Nuernberg)
On Tue, 7 Apr 2026, H.J. Lu wrote:
> On Tue, Apr 7, 2026 at 6:57 PM Richard Biener <rguenther@suse.de> wrote:
> >
> > On Tue, 7 Apr 2026, H.J. Lu wrote:
> >
> > > 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
> > >
> > > incorrectly uses GET_MODE_ALIGNMENT as memory alignment since memory
> > > alignment can be different from mode alignment as in
> > >
> > > (set (reg:OI 20 xmm0 [orig:112 s ] [112])
> > > (mem/c:OI (plus:DI (reg/f:DI 7 sp)
> > > (const_int -32 [0xffffffffffffffe0])) [3 s+0 S32 A128]))
> > >
> > > MEM_ALIGN should be used instead.
> >
> > LGTM if you add the PR reference and the testcase (I assume the
> > other patch had both).
>
> But this alone doesn't fix PR target/124759 and I couldn't find a testcase
> which makes a difference.
Ah, I see. Still OK then.
Richard.
> > Thanks,
> > Richard.
> >
> > > * config/i386/i386.cc (ix86_need_alignment_p_1): Replace
> > > GET_MODE_ALIGNMENT with MEM_ALIGN.
> > >
> > >
> > >
> >
> > --
> > Richard Biener <rguenther@suse.de>
> > SUSE Software Solutions Germany GmbH,
> > Frankenstrasse 146, 90461 Nuernberg, Germany;
> > GF: Jochen Jaser, Andrew McDonald, Werner Knoblich; (HRB 36809, AG Nuernberg)
>
>
>
>
From ab0ab385d5feffc62e9b25fda22279f5f1b71748 Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Tue, 7 Apr 2026 18:12:27 +0800
Subject: [PATCH] Update 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
incorrectly uses GET_MODE_ALIGNMENT as memory alignment since memory
alignment can be different from mode alignment as in
(set (reg:OI 20 xmm0 [orig:112 s ] [112])
(mem/c:OI (plus:DI (reg/f:DI 7 sp)
(const_int -32 [0xffffffffffffffe0])) [3 s+0 S32 A128]))
MEM_ALIGN should be used instead.
* config/i386/i386.cc (ix86_need_alignment_p_1): Replace
GET_MODE_ALIGNMENT with MEM_ALIGN.
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
---
gcc/config/i386/i386.cc | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
@@ -8789,7 +8789,7 @@ ix86_need_alignment_p_1 (rtx set, unsigned int alignment)
rtx dest = SET_DEST (set);
if (MEM_P (dest))
- return GET_MODE_ALIGNMENT (GET_MODE (dest)) > alignment;
+ return MEM_ALIGN (dest) > alignment;
const_rtx src = SET_SRC (set);
@@ -8799,7 +8799,7 @@ ix86_need_alignment_p_1 (rtx set, unsigned int alignment)
auto op = *iter;
if (MEM_P (op))
- return GET_MODE_ALIGNMENT (GET_MODE (op)) > alignment;
+ return MEM_ALIGN (op) > alignment;
}
return false;
--
2.53.0