aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Beulich <jbeulich@suse.com>2024-09-27 11:22:34 +0200
committerJan Beulich <jbeulich@suse.com>2024-09-27 11:22:34 +0200
commitf079b0c4b2923393c2ce58e72dfd5a1f2c7a339a (patch)
tree6e910f28ae19eb4c1d4280ec10e9ed7c145d0aae /gas/testsuite
parentx86: optimize {,V}EXTRACTPS with immediate 0 (diff)
downloadbinutils-gdb-f079b0c4b2923393c2ce58e72dfd5a1f2c7a339a.tar.gz
binutils-gdb-f079b0c4b2923393c2ce58e72dfd5a1f2c7a339a.tar.bz2
binutils-gdb-f079b0c4b2923393c2ce58e72dfd5a1f2c7a339a.zip
x86: optimize {,V}EXTRACT{F,I}{128,32x{4,8},64x{2,4}} with immediate 0
They, too, are equivalent to simple moves, which are up to 3 bytes shorter to encode (and maybe also cheaper to execute).
Diffstat (limited to 'gas/testsuite')
-rw-r--r--gas/testsuite/gas/i386/optimize-1.d20
-rw-r--r--gas/testsuite/gas/i386/optimize-1.s25
-rw-r--r--gas/testsuite/gas/i386/optimize-1a.d20
-rw-r--r--gas/testsuite/gas/i386/optimize-4.d20
-rw-r--r--gas/testsuite/gas/i386/optimize-5.d20
-rw-r--r--gas/testsuite/gas/i386/x86-64-optimize-vextractNN.d59
-rw-r--r--gas/testsuite/gas/i386/x86-64-optimize-vextractNN.s57
-rw-r--r--gas/testsuite/gas/i386/x86-64.exp1
8 files changed, 222 insertions, 0 deletions
diff --git a/gas/testsuite/gas/i386/optimize-1.d b/gas/testsuite/gas/i386/optimize-1.d
index c2802b894b9..fffa655d330 100644
--- a/gas/testsuite/gas/i386/optimize-1.d
+++ b/gas/testsuite/gas/i386/optimize-1.d
@@ -170,6 +170,26 @@ Disassembly of section .text:
+[a-f0-9]+: f3 .* movss %xmm1,\(%edx\)
+[a-f0-9]+: c5 .* vmovd %xmm1,%edx
+[a-f0-9]+: c5 .* vmovss %xmm1,\(%edx\)
+ +[a-f0-9]+: c5 .* vmovaps %xmm1,%xmm2
+ +[a-f0-9]+: c5 .* vmovups %xmm1,\(%edx\)
+ +[a-f0-9]+: c5 .* vmovdqa %xmm1,%xmm2
+ +[a-f0-9]+: c5 .* vmovdqu %xmm1,\(%edx\)
+ +[a-f0-9]+: c5 .* vmovaps %xmm1,%xmm2
+ +[a-f0-9]+: c5 .* vmovups %xmm1,\(%edx\)
+ +[a-f0-9]+: c5 .* vmovdqa %xmm1,%xmm2
+ +[a-f0-9]+: c5 .* vmovdqu %xmm1,\(%edx\)
+ +[a-f0-9]+: c5 .* vmovapd %xmm1,%xmm2
+ +[a-f0-9]+: c5 .* vmovupd %xmm1,\(%edx\)
+ +[a-f0-9]+: c5 .* vmovdqa %xmm1,%xmm2
+ +[a-f0-9]+: c5 .* vmovdqu %xmm1,\(%edx\)
+ +[a-f0-9]+: c5 .* vmovaps %ymm1,%ymm2
+ +[a-f0-9]+: c5 .* vmovups %ymm1,\(%edx\)
+ +[a-f0-9]+: c5 .* vmovdqa %ymm1,%ymm2
+ +[a-f0-9]+: c5 .* vmovdqu %ymm1,\(%edx\)
+ +[a-f0-9]+: c5 .* vmovapd %ymm1,%ymm2
+ +[a-f0-9]+: c5 .* vmovupd %ymm1,\(%edx\)
+ +[a-f0-9]+: c5 .* vmovdqa %ymm1,%ymm2
+ +[a-f0-9]+: c5 .* vmovdqu %ymm1,\(%edx\)
+[a-f0-9]+: 0f ba e0 0f bt \$0xf,%eax
+[a-f0-9]+: 66 0f ba e0 10 bt \$0x10,%ax
+[a-f0-9]+: 0f ba f8 0f btc \$0xf,%eax
diff --git a/gas/testsuite/gas/i386/optimize-1.s b/gas/testsuite/gas/i386/optimize-1.s
index 40546e8c157..afdeed4c423 100644
--- a/gas/testsuite/gas/i386/optimize-1.s
+++ b/gas/testsuite/gas/i386/optimize-1.s
@@ -199,6 +199,31 @@ _start:
vextractps $0, %xmm1, %edx
vextractps $0, %xmm1, (%edx)
+ vextractf128 $0, %ymm1, %xmm2
+ vextractf128 $0, %ymm1, (%edx)
+ vextracti128 $0, %ymm1, %xmm2
+ vextracti128 $0, %ymm1, (%edx)
+
+ vextractf32x4 $0, %ymm1, %xmm2
+ vextractf32x4 $0, %ymm1, (%edx)
+ vextracti32x4 $0, %ymm1, %xmm2
+ vextracti32x4 $0, %ymm1, (%edx)
+
+ vextractf64x2 $0, %ymm1, %xmm2
+ vextractf64x2 $0, %ymm1, (%edx)
+ vextracti64x2 $0, %ymm1, %xmm2
+ vextracti64x2 $0, %ymm1, (%edx)
+
+ vextractf32x8 $0, %zmm1, %ymm2
+ vextractf32x8 $0, %zmm1, (%edx)
+ vextracti32x8 $0, %zmm1, %ymm2
+ vextracti32x8 $0, %zmm1, (%edx)
+
+ vextractf64x4 $0, %zmm1, %ymm2
+ vextractf64x4 $0, %zmm1, (%edx)
+ vextracti64x4 $0, %zmm1, %ymm2
+ vextracti64x4 $0, %zmm1, (%edx)
+
bt $15, %ax
bt $16, %ax
btc $15, %ax
diff --git a/gas/testsuite/gas/i386/optimize-1a.d b/gas/testsuite/gas/i386/optimize-1a.d
index 563567f3f30..aff37681a00 100644
--- a/gas/testsuite/gas/i386/optimize-1a.d
+++ b/gas/testsuite/gas/i386/optimize-1a.d
@@ -171,6 +171,26 @@ Disassembly of section .text:
+[a-f0-9]+: f3 .* movss %xmm1,\(%edx\)
+[a-f0-9]+: c5 .* vmovd %xmm1,%edx
+[a-f0-9]+: c5 .* vmovss %xmm1,\(%edx\)
+ +[a-f0-9]+: c5 .* vmovaps %xmm1,%xmm2
+ +[a-f0-9]+: c5 .* vmovups %xmm1,\(%edx\)
+ +[a-f0-9]+: c5 .* vmovdqa %xmm1,%xmm2
+ +[a-f0-9]+: c5 .* vmovdqu %xmm1,\(%edx\)
+ +[a-f0-9]+: c5 .* vmovaps %xmm1,%xmm2
+ +[a-f0-9]+: c5 .* vmovups %xmm1,\(%edx\)
+ +[a-f0-9]+: c5 .* vmovdqa %xmm1,%xmm2
+ +[a-f0-9]+: c5 .* vmovdqu %xmm1,\(%edx\)
+ +[a-f0-9]+: c5 .* vmovapd %xmm1,%xmm2
+ +[a-f0-9]+: c5 .* vmovupd %xmm1,\(%edx\)
+ +[a-f0-9]+: c5 .* vmovdqa %xmm1,%xmm2
+ +[a-f0-9]+: c5 .* vmovdqu %xmm1,\(%edx\)
+ +[a-f0-9]+: c5 .* vmovaps %ymm1,%ymm2
+ +[a-f0-9]+: c5 .* vmovups %ymm1,\(%edx\)
+ +[a-f0-9]+: c5 .* vmovdqa %ymm1,%ymm2
+ +[a-f0-9]+: c5 .* vmovdqu %ymm1,\(%edx\)
+ +[a-f0-9]+: c5 .* vmovapd %ymm1,%ymm2
+ +[a-f0-9]+: c5 .* vmovupd %ymm1,\(%edx\)
+ +[a-f0-9]+: c5 .* vmovdqa %ymm1,%ymm2
+ +[a-f0-9]+: c5 .* vmovdqu %ymm1,\(%edx\)
+[a-f0-9]+: 0f ba e0 0f bt \$0xf,%eax
+[a-f0-9]+: 66 0f ba e0 10 bt \$0x10,%ax
+[a-f0-9]+: 0f ba f8 0f btc \$0xf,%eax
diff --git a/gas/testsuite/gas/i386/optimize-4.d b/gas/testsuite/gas/i386/optimize-4.d
index 2449bc55ad9..fbc142a424c 100644
--- a/gas/testsuite/gas/i386/optimize-4.d
+++ b/gas/testsuite/gas/i386/optimize-4.d
@@ -170,6 +170,26 @@ Disassembly of section .text:
+[a-f0-9]+: f3 .* movss %xmm1,\(%edx\)
+[a-f0-9]+: c5 .* vmovd %xmm1,%edx
+[a-f0-9]+: c5 .* vmovss %xmm1,\(%edx\)
+ +[a-f0-9]+: c5 .* vmovaps %xmm1,%xmm2
+ +[a-f0-9]+: c5 .* vmovups %xmm1,\(%edx\)
+ +[a-f0-9]+: c5 .* vmovdqa %xmm1,%xmm2
+ +[a-f0-9]+: c5 .* vmovdqu %xmm1,\(%edx\)
+ +[a-f0-9]+: c5 .* vmovaps %xmm1,%xmm2
+ +[a-f0-9]+: c5 .* vmovups %xmm1,\(%edx\)
+ +[a-f0-9]+: c5 .* vmovdqa %xmm1,%xmm2
+ +[a-f0-9]+: c5 .* vmovdqu %xmm1,\(%edx\)
+ +[a-f0-9]+: c5 .* vmovapd %xmm1,%xmm2
+ +[a-f0-9]+: c5 .* vmovupd %xmm1,\(%edx\)
+ +[a-f0-9]+: c5 .* vmovdqa %xmm1,%xmm2
+ +[a-f0-9]+: c5 .* vmovdqu %xmm1,\(%edx\)
+ +[a-f0-9]+: c5 .* vmovaps %ymm1,%ymm2
+ +[a-f0-9]+: c5 .* vmovups %ymm1,\(%edx\)
+ +[a-f0-9]+: c5 .* vmovdqa %ymm1,%ymm2
+ +[a-f0-9]+: c5 .* vmovdqu %ymm1,\(%edx\)
+ +[a-f0-9]+: c5 .* vmovapd %ymm1,%ymm2
+ +[a-f0-9]+: c5 .* vmovupd %ymm1,\(%edx\)
+ +[a-f0-9]+: c5 .* vmovdqa %ymm1,%ymm2
+ +[a-f0-9]+: c5 .* vmovdqu %ymm1,\(%edx\)
+[a-f0-9]+: 0f ba e0 0f bt \$0xf,%eax
+[a-f0-9]+: 66 0f ba e0 10 bt \$0x10,%ax
+[a-f0-9]+: 0f ba f8 0f btc \$0xf,%eax
diff --git a/gas/testsuite/gas/i386/optimize-5.d b/gas/testsuite/gas/i386/optimize-5.d
index d60d8421cbf..a40022a3420 100644
--- a/gas/testsuite/gas/i386/optimize-5.d
+++ b/gas/testsuite/gas/i386/optimize-5.d
@@ -170,6 +170,26 @@ Disassembly of section .text:
+[a-f0-9]+: f3 .* movss %xmm1,\(%edx\)
+[a-f0-9]+: c5 .* vmovd %xmm1,%edx
+[a-f0-9]+: c5 .* vmovss %xmm1,\(%edx\)
+ +[a-f0-9]+: c5 .* vmovaps %xmm1,%xmm2
+ +[a-f0-9]+: c5 .* vmovups %xmm1,\(%edx\)
+ +[a-f0-9]+: c5 .* vmovdqa %xmm1,%xmm2
+ +[a-f0-9]+: c5 .* vmovdqu %xmm1,\(%edx\)
+ +[a-f0-9]+: c5 .* vmovaps %xmm1,%xmm2
+ +[a-f0-9]+: c5 .* vmovups %xmm1,\(%edx\)
+ +[a-f0-9]+: c5 .* vmovdqa %xmm1,%xmm2
+ +[a-f0-9]+: c5 .* vmovdqu %xmm1,\(%edx\)
+ +[a-f0-9]+: c5 .* vmovapd %xmm1,%xmm2
+ +[a-f0-9]+: c5 .* vmovupd %xmm1,\(%edx\)
+ +[a-f0-9]+: c5 .* vmovdqa %xmm1,%xmm2
+ +[a-f0-9]+: c5 .* vmovdqu %xmm1,\(%edx\)
+ +[a-f0-9]+: c5 .* vmovaps %ymm1,%ymm2
+ +[a-f0-9]+: c5 .* vmovups %ymm1,\(%edx\)
+ +[a-f0-9]+: c5 .* vmovdqa %ymm1,%ymm2
+ +[a-f0-9]+: c5 .* vmovdqu %ymm1,\(%edx\)
+ +[a-f0-9]+: c5 .* vmovapd %ymm1,%ymm2
+ +[a-f0-9]+: c5 .* vmovupd %ymm1,\(%edx\)
+ +[a-f0-9]+: c5 .* vmovdqa %ymm1,%ymm2
+ +[a-f0-9]+: c5 .* vmovdqu %ymm1,\(%edx\)
+[a-f0-9]+: 0f ba e0 0f bt \$0xf,%eax
+[a-f0-9]+: 66 0f ba e0 10 bt \$0x10,%ax
+[a-f0-9]+: 0f ba f8 0f btc \$0xf,%eax
diff --git a/gas/testsuite/gas/i386/x86-64-optimize-vextractNN.d b/gas/testsuite/gas/i386/x86-64-optimize-vextractNN.d
new file mode 100644
index 00000000000..739a2fbb54a
--- /dev/null
+++ b/gas/testsuite/gas/i386/x86-64-optimize-vextractNN.d
@@ -0,0 +1,59 @@
+#as: -O
+#objdump: -drw
+#name: x86-64 VEXTRACT{F,I}<nn> optimized encoding with -msse2avx
+
+.*: +file format .*
+
+
+Disassembly of section .text:
+
+0+ <vextract_128>:
+ +[a-f0-9]+: c5 f8 29 ca vmovaps %xmm1,%xmm2
+ +[a-f0-9]+: c5 f8 11 0a vmovups %xmm1,\(%rdx\)
+ +[a-f0-9]+: c5 f9 7f ca vmovdqa %xmm1,%xmm2
+ +[a-f0-9]+: c5 fa 7f 0a vmovdqu %xmm1,\(%rdx\)
+
+0+[a-f0-9]+ <vextract_NNxM_XMM>:
+ +[a-f0-9]+: c5 f8 29 ca vmovaps %xmm1,%xmm2
+ +[a-f0-9]+: c5 f8 11 0a vmovups %xmm1,\(%rdx\)
+ +[a-f0-9]+: 62 e1 7c 08 29 ca vmovaps %xmm17,%xmm2
+ +[a-f0-9]+: 62 e1 7c 08 11 0a vmovups %xmm17,\(%rdx\)
+ +[a-f0-9]+: 62 f9 7c 08 11 0a vmovups %xmm1,\(%r18\)
+ +[a-f0-9]+: c5 f9 29 ca vmovapd %xmm1,%xmm2
+ +[a-f0-9]+: c5 f9 11 0a vmovupd %xmm1,\(%rdx\)
+ +[a-f0-9]+: 62 e1 fd 08 29 ca vmovapd %xmm17,%xmm2
+ +[a-f0-9]+: 62 e1 fd 08 11 0a vmovupd %xmm17,\(%rdx\)
+ +[a-f0-9]+: 62 f9 fd 08 11 0a vmovupd %xmm1,\(%r18\)
+ +[a-f0-9]+: c5 f9 7f ca vmovdqa %xmm1,%xmm2
+ +[a-f0-9]+: c5 fa 7f 0a vmovdqu %xmm1,\(%rdx\)
+ +[a-f0-9]+: 62 e1 7d 08 7f ca vmovdqa32 %xmm17,%xmm2
+ +[a-f0-9]+: 62 e1 7e 08 7f 0a vmovdqu32 %xmm17,\(%rdx\)
+ +[a-f0-9]+: 62 f9 7e 08 7f 0a vmovdqu32 %xmm1,\(%r18\)
+ +[a-f0-9]+: c5 f9 7f ca vmovdqa %xmm1,%xmm2
+ +[a-f0-9]+: c5 fa 7f 0a vmovdqu %xmm1,\(%rdx\)
+ +[a-f0-9]+: 62 e1 fd 08 7f ca vmovdqa64 %xmm17,%xmm2
+ +[a-f0-9]+: 62 e1 fe 08 7f 0a vmovdqu64 %xmm17,\(%rdx\)
+ +[a-f0-9]+: 62 f9 fe 08 7f 0a vmovdqu64 %xmm1,\(%r18\)
+
+0+[a-f0-9]+ <vextract_NNxM_YMM>:
+ +[a-f0-9]+: c5 fc 29 ca vmovaps %ymm1,%ymm2
+ +[a-f0-9]+: c5 fc 11 0a vmovups %ymm1,\(%rdx\)
+ +[a-f0-9]+: 62 e1 7c 28 29 ca vmovaps %ymm17,%ymm2
+ +[a-f0-9]+: 62 e1 7c 28 11 0a vmovups %ymm17,\(%rdx\)
+ +[a-f0-9]+: 62 f9 7c 28 11 0a vmovups %ymm1,\(%r18\)
+ +[a-f0-9]+: c5 fd 29 ca vmovapd %ymm1,%ymm2
+ +[a-f0-9]+: c5 fd 11 0a vmovupd %ymm1,\(%rdx\)
+ +[a-f0-9]+: 62 e1 fd 28 29 ca vmovapd %ymm17,%ymm2
+ +[a-f0-9]+: 62 e1 fd 28 11 0a vmovupd %ymm17,\(%rdx\)
+ +[a-f0-9]+: 62 f9 fd 28 11 0a vmovupd %ymm1,\(%r18\)
+ +[a-f0-9]+: c5 fd 7f ca vmovdqa %ymm1,%ymm2
+ +[a-f0-9]+: c5 fe 7f 0a vmovdqu %ymm1,\(%rdx\)
+ +[a-f0-9]+: 62 e1 7d 28 7f ca vmovdqa32 %ymm17,%ymm2
+ +[a-f0-9]+: 62 e1 7e 28 7f 0a vmovdqu32 %ymm17,\(%rdx\)
+ +[a-f0-9]+: 62 f9 7e 28 7f 0a vmovdqu32 %ymm1,\(%r18\)
+ +[a-f0-9]+: c5 fd 7f ca vmovdqa %ymm1,%ymm2
+ +[a-f0-9]+: c5 fe 7f 0a vmovdqu %ymm1,\(%rdx\)
+ +[a-f0-9]+: 62 e1 fd 28 7f ca vmovdqa64 %ymm17,%ymm2
+ +[a-f0-9]+: 62 e1 fe 28 7f 0a vmovdqu64 %ymm17,\(%rdx\)
+ +[a-f0-9]+: 62 f9 fe 28 7f 0a vmovdqu64 %ymm1,\(%r18\)
+#pass
diff --git a/gas/testsuite/gas/i386/x86-64-optimize-vextractNN.s b/gas/testsuite/gas/i386/x86-64-optimize-vextractNN.s
new file mode 100644
index 00000000000..5da8265d345
--- /dev/null
+++ b/gas/testsuite/gas/i386/x86-64-optimize-vextractNN.s
@@ -0,0 +1,57 @@
+ .text
+vextract_128:
+ vextractf128 $0, %ymm1, %xmm2
+ vextractf128 $0, %ymm1, (%rdx)
+
+ vextracti128 $0, %ymm1, %xmm2
+ vextracti128 $0, %ymm1, (%rdx)
+
+vextract_NNxM_XMM:
+ vextractf32x4 $0, %ymm1, %xmm2
+ vextractf32x4 $0, %ymm1, (%rdx)
+ vextractf32x4 $0, %ymm17, %xmm2
+ vextractf32x4 $0, %ymm17, (%rdx)
+ vextractf32x4 $0, %ymm1, (%r18)
+
+ vextractf64x2 $0, %ymm1, %xmm2
+ vextractf64x2 $0, %ymm1, (%rdx)
+ vextractf64x2 $0, %ymm17, %xmm2
+ vextractf64x2 $0, %ymm17, (%rdx)
+ vextractf64x2 $0, %ymm1, (%r18)
+
+ vextracti32x4 $0, %ymm1, %xmm2
+ vextracti32x4 $0, %ymm1, (%rdx)
+ vextracti32x4 $0, %ymm17, %xmm2
+ vextracti32x4 $0, %ymm17, (%rdx)
+ vextracti32x4 $0, %ymm1, (%r18)
+
+ vextracti64x2 $0, %ymm1, %xmm2
+ vextracti64x2 $0, %ymm1, (%rdx)
+ vextracti64x2 $0, %ymm17, %xmm2
+ vextracti64x2 $0, %ymm17, (%rdx)
+ vextracti64x2 $0, %ymm1, (%r18)
+
+vextract_NNxM_YMM:
+ vextractf32x8 $0, %zmm1, %ymm2
+ vextractf32x8 $0, %zmm1, (%rdx)
+ vextractf32x8 $0, %zmm17, %ymm2
+ vextractf32x8 $0, %zmm17, (%rdx)
+ vextractf32x8 $0, %zmm1, (%r18)
+
+ vextractf64x4 $0, %zmm1, %ymm2
+ vextractf64x4 $0, %zmm1, (%rdx)
+ vextractf64x4 $0, %zmm17, %ymm2
+ vextractf64x4 $0, %zmm17, (%rdx)
+ vextractf64x4 $0, %zmm1, (%r18)
+
+ vextracti32x8 $0, %zmm1, %ymm2
+ vextracti32x8 $0, %zmm1, (%rdx)
+ vextracti32x8 $0, %zmm17, %ymm2
+ vextracti32x8 $0, %zmm17, (%rdx)
+ vextracti32x8 $0, %zmm1, (%r18)
+
+ vextracti64x4 $0, %zmm1, %ymm2
+ vextracti64x4 $0, %zmm1, (%rdx)
+ vextracti64x4 $0, %zmm17, %ymm2
+ vextracti64x4 $0, %zmm17, (%rdx)
+ vextracti64x4 $0, %zmm1, (%r18)
diff --git a/gas/testsuite/gas/i386/x86-64.exp b/gas/testsuite/gas/i386/x86-64.exp
index 61fafd07a8c..ad713dc59ae 100644
--- a/gas/testsuite/gas/i386/x86-64.exp
+++ b/gas/testsuite/gas/i386/x86-64.exp
@@ -596,6 +596,7 @@ run_list_test "x86-64-optimize-pextr" "-O -aln"
run_dump_test "x86-64-optimize-pextr"
run_list_test "x86-64-optimize-extractps" "-O -aln"
run_dump_test "x86-64-optimize-extractps"
+run_dump_test "x86-64-optimize-vextractNN"
run_dump_test "x86-64-apx-ndd-optimize"
run_dump_test "x86-64-align-branch-1a"
run_dump_test "x86-64-align-branch-1b"