[APX,PUSH2POP2] Adjust operand order for PUSH2POP2

Message ID 20231122033108.3654950-1-hongyu.wang@intel.com
State Unresolved
Headers
Series [APX,PUSH2POP2] Adjust operand order for PUSH2POP2 |

Checks

Context Check Description
snail/gcc-patch-check warning Git am fail log

Commit Message

Hongyu Wang Nov. 22, 2023, 3:31 a.m. UTC
  Hi,

The push2/pop2 operand order does not match the binutils implementation
for AT&T syntax that it will first push operands[2] then operands[1].
Correct it by reverse operand order for AT&T syntax.

Bootstrapped/regtested on x86-64-linux-pc-gnu{-m32,}

Ok for master?

gcc/ChangeLog:

	* config/i386/i386.md (push2_di): Adjust operand order for AT&T
	syntax.
	(pop2_di): Likewise.
	(push2p_di): Likewise.
	(pop2p_di): Likewise.

gcc/testsuite/ChangeLog:

	* gcc.target/i386/apx-push2pop2-1.c: Adjust output scan.
	* gcc.target/i386/apx-push2pop2_force_drap-1.c: Likewise.
---
 gcc/config/i386/i386.md                                   | 8 ++++----
 gcc/testsuite/gcc.target/i386/apx-push2pop2-1.c           | 8 ++++----
 .../gcc.target/i386/apx-push2pop2_force_drap-1.c          | 8 ++++----
 3 files changed, 12 insertions(+), 12 deletions(-)
  

Patch

diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md
index 03e4ddd3037..99bb909b244 100644
--- a/gcc/config/i386/i386.md
+++ b/gcc/config/i386/i386.md
@@ -3772,7 +3772,7 @@  (define_insn "push2_di"
 		    (match_operand:DI 2 "register_operand" "r")]
 		    UNSPEC_APXPUSH2))]
   "TARGET_APX_PUSH2POP2"
-  "push2\t%1, %2"
+  "push2\t{%2, %1|%1, %2}"
   [(set_attr "mode" "TI")
    (set_attr "type" "multi")
    (set_attr "prefix" "evex")])
@@ -3784,7 +3784,7 @@  (define_insn "pop2_di"
 	      (set (match_operand:DI 2 "register_operand" "=r")
 		   (unspec:DI [(const_int 0)] UNSPEC_APXPOP2_HIGH))])]
   "TARGET_APX_PUSH2POP2"
-  "pop2\t%0, %2"
+  "pop2\t{%2, %0|%0, %2}"
   [(set_attr "mode" "TI")
    (set_attr "prefix" "evex")])
 
@@ -3811,7 +3811,7 @@  (define_insn "push2p_di"
 		    UNSPEC_APXPUSH2))
    (unspec:DI [(const_int 0)] UNSPEC_APX_PPX)]
   "TARGET_APX_PUSH2POP2 && TARGET_APX_PPX"
-  "push2p\t%1, %2"
+  "push2p\t{%2, %1|%1, %2}"
   [(set_attr "mode" "TI")
    (set_attr "type" "multi")
    (set_attr "prefix" "evex")])
@@ -3824,7 +3824,7 @@  (define_insn "pop2p_di"
 		   (unspec:DI [(const_int 0)] UNSPEC_APXPOP2_HIGH))
 	      (unspec:DI [(const_int 0)] UNSPEC_APX_PPX)])]
   "TARGET_APX_PUSH2POP2 && TARGET_APX_PPX"
-  "pop2p\t%0, %2"
+  "pop2p\t{%2, %0|%0, %2}"
   [(set_attr "mode" "TI")
    (set_attr "prefix" "evex")])
 
diff --git a/gcc/testsuite/gcc.target/i386/apx-push2pop2-1.c b/gcc/testsuite/gcc.target/i386/apx-push2pop2-1.c
index c53112758a5..d78c96d36a3 100644
--- a/gcc/testsuite/gcc.target/i386/apx-push2pop2-1.c
+++ b/gcc/testsuite/gcc.target/i386/apx-push2pop2-1.c
@@ -24,11 +24,11 @@  void foo ()
 /* { dg-final { scan-assembler-times ".cfi_def_cfa_offset 16" 2 } } */
 /* { dg-final { scan-assembler-times "pushq\[^\n\r]*%r15(?:\n|\[ \\t\]+#)" 1 } } */
 /* { dg-final { scan-assembler-times ".cfi_offset 15, -16(?:\n|\[ \\t\]+#)" 1 } } */
-/* { dg-final { scan-assembler-times "push2\[\\t \]*\[^\n\r]*%r14\[^\n\r]*%r13\[^\n\r]*(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "push2\[\\t \]*\[^\n\r]*%r13\[^\n\r]*%r14\[^\n\r]*(?:\n|\[ \\t\]+#)" 1 } } */
 /* { dg-final { scan-assembler-times ".cfi_def_cfa_offset 32" 2 } } */
 /* { dg-final { scan-assembler-times ".cfi_offset 14, -24(?:\n|\[ \\t\]+#)" 1 } } */
 /* { dg-final { scan-assembler-times ".cfi_offset 13, -32(?:\n|\[ \\t\]+#)" 1 } } */
-/* { dg-final { scan-assembler-times "push2\[\\t \]*\[^\n\r]*%r12\[^\n\r]*%rbp\[^\n\r]*(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "push2\[\\t \]*\[^\n\r]*%rbp\[^\n\r]*%r12\[^\n\r]*(?:\n|\[ \\t\]+#)" 1 } } */
 /* { dg-final { scan-assembler-times ".cfi_def_cfa_offset 48" 2 } } */
 /* { dg-final { scan-assembler-times ".cfi_offset 12, -40(?:\n|\[ \\t\]+#)" 1 } } */
 /* { dg-final { scan-assembler-times ".cfi_offset 6, -48(?:\n|\[ \\t\]+#)" 1 } } */
@@ -36,10 +36,10 @@  void foo ()
 /* { dg-final { scan-assembler-times ".cfi_def_cfa_offset 56" 2 } } */
 /* { dg-final { scan-assembler-times ".cfi_offset 3, -56(?:\n|\[ \\t\]+#)" 1 } } */
 /* { dg-final { scan-assembler-times "popq\[^\n\r]*rbx(?:\n|\[ \\t\]+#)" 1 } } */
-/* { dg-final { scan-assembler-times "pop2\[\\t \]*\[^\n\r]*%rbp\[^\n\r]*%r12\[^\n\r]*(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "pop2\[\\t \]*\[^\n\r]*%r12\[^\n\r]*%rbp\[^\n\r]*(?:\n|\[ \\t\]+#)" 1 } } */
 /* { dg-final { scan-assembler-times ".cfi_restore 12(?:\n|\[ \\t\]+#)" 1 } } */
 /* { dg-final { scan-assembler-times ".cfi_restore 6(?:\n|\[ \\t\]+#)" 1 } } */
-/* { dg-final { scan-assembler-times "pop2\[\\t \]*\[^\n\r]*%r13\[^\n\r]*%r14\[^\n\r]*(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "pop2\[\\t \]*\[^\n\r]*%r14\[^\n\r]*%r13\[^\n\r]*(?:\n|\[ \\t\]+#)" 1 } } */
 /* { dg-final { scan-assembler-times ".cfi_restore 14(?:\n|\[ \\t\]+#)" 1 } } */
 /* { dg-final { scan-assembler-times ".cfi_restore 13(?:\n|\[ \\t\]+#)" 1 } } */
 /* { dg-final { scan-assembler-times "popq\[^\n\r]*%r15(?:\n|\[ \\t\]+#)" 1 } } */
diff --git a/gcc/testsuite/gcc.target/i386/apx-push2pop2_force_drap-1.c b/gcc/testsuite/gcc.target/i386/apx-push2pop2_force_drap-1.c
index 022113bb1e2..3cac7b10769 100644
--- a/gcc/testsuite/gcc.target/i386/apx-push2pop2_force_drap-1.c
+++ b/gcc/testsuite/gcc.target/i386/apx-push2pop2_force_drap-1.c
@@ -8,11 +8,11 @@ 
 /* { dg-final { scan-assembler-times ".cfi_def_cfa_offset 16" 2 } } */
 /* { dg-final { scan-assembler-times "pushq\[^\n\r]*%r15(?:\n|\[ \\t\]+#)" 1 } } */
 /* { dg-final { scan-assembler-times ".cfi_offset 15, -16(?:\n|\[ \\t\]+#)" 1 } } */
-/* { dg-final { scan-assembler-times "push2\[\\t \]*\[^\n\r]*%r14\[^\n\r]*%r13\[^\n\r]*(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "push2\[\\t \]*\[^\n\r]*%r13\[^\n\r]*%r14\[^\n\r]*(?:\n|\[ \\t\]+#)" 1 } } */
 /* { dg-final { scan-assembler-times ".cfi_def_cfa_offset 32" 2 } } */
 /* { dg-final { scan-assembler-times ".cfi_offset 14, -24(?:\n|\[ \\t\]+#)" 1 } } */
 /* { dg-final { scan-assembler-times ".cfi_offset 13, -32(?:\n|\[ \\t\]+#)" 1 } } */
-/* { dg-final { scan-assembler-times "push2\[\\t \]*\[^\n\r]*%r12\[^\n\r]*%rbp\[^\n\r]*(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "push2\[\\t \]*\[^\n\r]*%rbp\[^\n\r]*%r12\[^\n\r]*(?:\n|\[ \\t\]+#)" 1 } } */
 /* { dg-final { scan-assembler-times ".cfi_def_cfa_offset 48" 2 } } */
 /* { dg-final { scan-assembler-times ".cfi_offset 12, -40(?:\n|\[ \\t\]+#)" 1 } } */
 /* { dg-final { scan-assembler-times ".cfi_offset 6, -48(?:\n|\[ \\t\]+#)" 1 } } */
@@ -20,10 +20,10 @@ 
 /* { dg-final { scan-assembler-times ".cfi_def_cfa_offset 56" 2 } } */
 /* { dg-final { scan-assembler-times ".cfi_offset 3, -56(?:\n|\[ \\t\]+#)" 1 } } */
 /* { dg-final { scan-assembler-times "popq\[^\n\r]*rbx(?:\n|\[ \\t\]+#)" 1 } } */
-/* { dg-final { scan-assembler-times "pop2\[\\t \]*\[^\n\r]*%rbp\[^\n\r]*%r12\[^\n\r]*(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "pop2\[\\t \]*\[^\n\r]*%r12\[^\n\r]*%rbp\[^\n\r]*(?:\n|\[ \\t\]+#)" 1 } } */
 /* { dg-final { scan-assembler-times ".cfi_restore 12(?:\n|\[ \\t\]+#)" 1 } } */
 /* { dg-final { scan-assembler-times ".cfi_restore 6(?:\n|\[ \\t\]+#)" 1 } } */
-/* { dg-final { scan-assembler-times "pop2\[\\t \]*\[^\n\r]*%r13\[^\n\r]*%r14\[^\n\r]*(?:\n|\[ \\t\]+#)" 1 } } */
+/* { dg-final { scan-assembler-times "pop2\[\\t \]*\[^\n\r]*%r14\[^\n\r]*%r13\[^\n\r]*(?:\n|\[ \\t\]+#)" 1 } } */
 /* { dg-final { scan-assembler-times ".cfi_restore 14(?:\n|\[ \\t\]+#)" 1 } } */
 /* { dg-final { scan-assembler-times ".cfi_restore 13(?:\n|\[ \\t\]+#)" 1 } } */
 /* { dg-final { scan-assembler-times "popq\[^\n\r]*%r15(?:\n|\[ \\t\]+#)" 1 } } */