From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2153) id 11284395250C; Tue, 2 May 2023 20:16:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 11284395250C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1683058584; bh=mSzV/6iHqxf7GKek13xrTyvsoVxj7/YJ7IDRFTWsbSw=; h=From:To:Subject:Date:From; b=a2K7BOAXOM4NgdXrCBlJ24LL9+NkdenTLN1bW5coEiJ7FKEtiCXdgARFX+x4hWaA4 a+7a641BlIybR3nmDL0W6P40N49YRAk+1wnLzBee3bGQgf1lxCeqlPfPXr+FFeoztE kGAuiFUo/Zip1j/Yn0FBxNntUVdIYJYWof3souQY= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jakub Jelinek To: gcc-cvs@gcc.gnu.org Subject: [gcc r11-10731] i386: Require just 32-bit alignment for SLOT_FLOATxFDI_387 -m32 -mpreferred-stack-boundary=2 DImode X-Act-Checkin: gcc X-Git-Author: Jakub Jelinek X-Git-Refname: refs/heads/releases/gcc-11 X-Git-Oldrev: c448f0d85c778eade1d8ae597744f6455285346f X-Git-Newrev: 623245bc3f4eed25db80dd5f5650c18cd7314b39 Message-Id: <20230502201624.11284395250C@sourceware.org> Date: Tue, 2 May 2023 20:16:24 +0000 (GMT) List-Id: https://gcc.gnu.org/g:623245bc3f4eed25db80dd5f5650c18cd7314b39 commit r11-10731-g623245bc3f4eed25db80dd5f5650c18cd7314b39 Author: Jakub Jelinek Date: Tue Mar 28 10:43:08 2023 +0200 i386: Require just 32-bit alignment for SLOT_FLOATxFDI_387 -m32 -mpreferred-stack-boundary=2 DImode temporaries [PR109276] The following testcase ICEs since r11-2259 because assign_386_stack_local -> assign_stack_local -> ix86_local_alignment now uses 64-bit alignment for DImode temporaries rather than 32-bit as before. Most of the spots in the backend which ask for DImode temporaries are during expansion and those apparently are handled fine with -m32 -mpreferred-stack-boundary=2, we dynamically realign the stack in that case (most of the spots actually don't need that alignment but at least one does), then 2 spots are in STV which I assume also work correctly. But during splitting we can create a DImode slot which doesn't need to be 64-bit alignment (it is nicer for performance though), when we apparently aren't able to detect it for dynamic stack realignment purposes. The following patch just makes the slot 32-bit aligned in that rare case. 2023-03-28 Jakub Jelinek PR target/109276 * config/i386/i386.c (assign_386_stack_local): For DImode with SLOT_FLOATxFDI_387 and -m32 -mpreferred-stack-boundary=2 pass align 32 rather than 0 to assign_stack_local. * gcc.target/i386/pr109276.c: New test. (cherry picked from commit 4b5ef857f5faf09f274c0a95c67faaa80d198124) Diff: --- gcc/config/i386/i386.c | 10 +++++++++- gcc/testsuite/gcc.target/i386/pr109276.c | 13 +++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index 9832d4e0320..6c9c99ee50b 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -16217,10 +16217,18 @@ assign_386_stack_local (machine_mode mode, enum ix86_stack_slot n) if (s->mode == mode && s->n == n) return validize_mem (copy_rtx (s->rtl)); + int align = 0; + /* For DImode with SLOT_FLOATxFDI_387 use 32-bit + alignment with -m32 -mpreferred-stack-boundary=2. */ + if (mode == DImode + && !TARGET_64BIT + && n == SLOT_FLOATxFDI_387 + && ix86_preferred_stack_boundary < GET_MODE_ALIGNMENT (DImode)) + align = 32; s = ggc_alloc (); s->n = n; s->mode = mode; - s->rtl = assign_stack_local (mode, GET_MODE_SIZE (mode), 0); + s->rtl = assign_stack_local (mode, GET_MODE_SIZE (mode), align); s->next = ix86_stack_locals; ix86_stack_locals = s; diff --git a/gcc/testsuite/gcc.target/i386/pr109276.c b/gcc/testsuite/gcc.target/i386/pr109276.c new file mode 100644 index 00000000000..5d0827aa280 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr109276.c @@ -0,0 +1,13 @@ +/* PR target/109276 */ +/* { dg-do compile } */ +/* { dg-options "-march=x86-64" } */ +/* { dg-additional-options "-mpreferred-stack-boundary=2" { target ia32 } } */ + +long long a; +long double b; + +void +foo (void) +{ + b += a; +}