From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1039) id 02B73388B80E; Mon, 2 Aug 2021 17:41:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 02B73388B80E MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: H.J. Lu To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-2665] x86: Avoid stack realignment when copying data X-Act-Checkin: gcc X-Git-Author: H.J. Lu X-Git-Refname: refs/heads/master X-Git-Oldrev: 1bee034e012d1146d34b0d767fe28a485c210e4b X-Git-Newrev: 7f4c3943f795fda33df648d2196b678bada1ba81 Message-Id: <20210802174114.02B73388B80E@sourceware.org> Date: Mon, 2 Aug 2021 17:41:14 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 02 Aug 2021 17:41:14 -0000 https://gcc.gnu.org/g:7f4c3943f795fda33df648d2196b678bada1ba81 commit r12-2665-g7f4c3943f795fda33df648d2196b678bada1ba81 Author: H.J. Lu Date: Mon Aug 2 10:01:46 2021 -0700 x86: Avoid stack realignment when copying data To avoid stack realignment, use SCRATCH_SSE_REG to copy data from one memory location to another. gcc/ * config/i386/i386-expand.c (ix86_expand_vector_move): Call ix86_gen_scratch_sse_rtx to get a scratch SSE register to copy data from one memory location to another. gcc/testsuite/ * gcc.target/i386/eh_return-1.c: New test. Diff: --- gcc/config/i386/i386-expand.c | 4 +++- gcc/testsuite/gcc.target/i386/eh_return-1.c | 26 ++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/gcc/config/i386/i386-expand.c b/gcc/config/i386/i386-expand.c index 896bd685b1f..1d469bf7221 100644 --- a/gcc/config/i386/i386-expand.c +++ b/gcc/config/i386/i386-expand.c @@ -625,7 +625,9 @@ ix86_expand_vector_move (machine_mode mode, rtx operands[]) && !register_operand (op0, mode) && !register_operand (op1, mode)) { - emit_move_insn (op0, force_reg (GET_MODE (op0), op1)); + rtx tmp = ix86_gen_scratch_sse_rtx (GET_MODE (op0)); + emit_move_insn (tmp, op1); + emit_move_insn (op0, tmp); return; } diff --git a/gcc/testsuite/gcc.target/i386/eh_return-1.c b/gcc/testsuite/gcc.target/i386/eh_return-1.c new file mode 100644 index 00000000000..671ba635e88 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/eh_return-1.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -march=haswell -mno-avx512f" } */ + +struct _Unwind_Context +{ + void *ra; + char array[48]; +}; + +extern long uw_install_context_1 (struct _Unwind_Context *); + +void +_Unwind_RaiseException (void) +{ + struct _Unwind_Context this_context, cur_context; + long offset = uw_install_context_1 (&this_context); + __builtin_memcpy (&this_context, &cur_context, + sizeof (struct _Unwind_Context)); + void *handler = __builtin_frob_return_addr ((&cur_context)->ra); + uw_install_context_1 (&cur_context); + __builtin_eh_return (offset, handler); +} + +/* { dg-final { scan-assembler-times "vmovdqu\[ \\t\]+\[^\n\]*%ymm" 4 } } */ +/* No need to dynamically realign the stack here. */ +/* { dg-final { scan-assembler-not "and\[^\n\r]*%\[re\]sp" } } */