]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
x86: Avoid stack realignment when copying data with SSE register
authorH.J. Lu <hjl.tools@gmail.com>
Wed, 4 Aug 2021 13:15:04 +0000 (06:15 -0700)
committerH.J. Lu <hjl.tools@gmail.com>
Wed, 4 Aug 2021 19:51:12 +0000 (12:51 -0700)
To avoid stack realignment, call ix86_gen_scratch_sse_rtx to get a
scratch SSE register to copy data with with SSE register from one
memory location to another.

gcc/

PR target/101772
* config/i386/i386-expand.c (ix86_expand_vector_move): Call
ix86_gen_scratch_sse_rtx to get a scratch SSE register to copy
data with SSE register from one memory location to another.

gcc/testsuite/

PR target/101772
* gcc.target/i386/eh_return-2.c: New test.

gcc/config/i386/i386-expand.c
gcc/testsuite/gcc.target/i386/eh_return-2.c [new file with mode: 0644]

index 1d469bf7221234b5b8467145b2d7750b4d19e50e..bd21efa9530458b178b72ac833e909ffd35fb71d 100644 (file)
@@ -613,7 +613,11 @@ ix86_expand_vector_move (machine_mode mode, rtx operands[])
         arguments in memory.  */
       if (!register_operand (op0, mode)
          && !register_operand (op1, mode))
-       op1 = force_reg (mode, op1);
+       {
+         rtx scratch = ix86_gen_scratch_sse_rtx (mode);
+         emit_move_insn (scratch, op1);
+         op1 = scratch;
+       }
 
       tmp[0] = op0; tmp[1] = op1;
       ix86_expand_vector_move_misalign (mode, tmp);
diff --git a/gcc/testsuite/gcc.target/i386/eh_return-2.c b/gcc/testsuite/gcc.target/i386/eh_return-2.c
new file mode 100644 (file)
index 0000000..f23f449
--- /dev/null
@@ -0,0 +1,16 @@
+/* PR target/101772  */
+/* { dg-do compile } */
+/* { dg-additional-options "-O0 -march=x86-64 -mstackrealign" } */
+
+struct _Unwind_Context _Unwind_Resume_or_Rethrow_this_context;
+
+void offset (int);
+
+struct _Unwind_Context {
+  void *reg[7];
+} _Unwind_Resume_or_Rethrow() {
+  struct _Unwind_Context cur_contextcur_context =
+      _Unwind_Resume_or_Rethrow_this_context;
+  offset(0);
+  __builtin_eh_return ((long) offset, 0);
+}