aboutsummaryrefslogtreecommitdiff
path: root/gas
diff options
context:
space:
mode:
authorJan Beulich <jbeulich@novell.com>2018-07-31 10:58:05 +0200
committerJan Beulich <jbeulich@suse.com>2018-07-31 10:58:05 +0200
commit1424ad867742286be44932bf29720539add19ae0 (patch)
tree5461a39c1b53637faccaf9b1abab4cbf85fa8bf1 /gas
parentae2387feae3f0798dd77c98a7107fdec38a99fe3 (diff)
downloadbinutils-1424ad867742286be44932bf29720539add19ae0.zip
binutils-1424ad867742286be44932bf29720539add19ae0.tar.gz
binutils-1424ad867742286be44932bf29720539add19ae0.tar.bz2
x86: also optimize KXOR{D,Q} and KANDN{D,Q}
These can be converted to 2-byte VEX encoding when both source registers are the same, by using KXORW / KANDNW as replacement.
Diffstat (limited to 'gas')
-rw-r--r--gas/ChangeLog9
-rw-r--r--gas/config/tc-i386.c17
-rw-r--r--gas/testsuite/gas/i386/optimize-1.d4
-rw-r--r--gas/testsuite/gas/i386/optimize-1.s6
-rw-r--r--gas/testsuite/gas/i386/optimize-4.d4
-rw-r--r--gas/testsuite/gas/i386/optimize-5.d4
6 files changed, 43 insertions, 1 deletions
diff --git a/gas/ChangeLog b/gas/ChangeLog
index 4472821..9682f66 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,5 +1,14 @@
2018-07-31 Jan Beulich <jbeulich@suse.com>
+ * config/tc-i386.c (optimize_encoding): Also handle kandnd,
+ kandnq, kxord, and kxorq.
+ * testsuite/gas/i386/optimize-1.s: Add kandn and kxor tests.
+ * testsuite/gas/i386/optimize-1.d,
+ testsuite/gas/i386/optimize-4.d,
+ testsuite/gas/i386/optimize-5.d: Adjust expectations.
+
+2018-07-31 Jan Beulich <jbeulich@suse.com>
+
* config/tc-i386.c (check_VecOperands): Convert masking handling
to switch(), to deal with DYNAMIC_MASKING.
diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c
index 8761e97..e07056f 100644
--- a/gas/config/tc-i386.c
+++ b/gas/config/tc-i386.c
@@ -3942,7 +3942,11 @@ optimize_encoding (void)
|| i.tm.base_opcode == 0x66f8
|| i.tm.base_opcode == 0x66f9
|| i.tm.base_opcode == 0x66fa
- || i.tm.base_opcode == 0x66fb)
+ || i.tm.base_opcode == 0x66fb
+ || i.tm.base_opcode == 0x42
+ || i.tm.base_opcode == 0x6642
+ || i.tm.base_opcode == 0x47
+ || i.tm.base_opcode == 0x6647)
&& i.tm.extension_opcode == None))
{
/* Optimize: -O2:
@@ -3973,6 +3977,12 @@ optimize_encoding (void)
EVEX VOP %ymmM, %ymmM, %ymmN
-> VEX vpxor %xmmM, %xmmM, %xmmN (M and N < 16)
-> EVEX VOP %xmmM, %xmmM, %xmmN (M || N >= 16)
+ VOP, one of kxord and kxorq:
+ VEX VOP %kM, %kM, %kN
+ -> VEX kxorw %kM, %kM, %kN
+ VOP, one of kandnd and kandnq:
+ VEX VOP %kM, %kM, %kN
+ -> VEX kandnw %kM, %kM, %kN
*/
if (is_evex_encoding (&i.tm))
{
@@ -3985,6 +3995,11 @@ optimize_encoding (void)
i.tm.opcode_modifier.evex = 0;
}
}
+ else if (i.tm.operand_types[0].bitfield.regmask)
+ {
+ i.tm.base_opcode &= 0xff;
+ i.tm.opcode_modifier.vexw = VEXW0;
+ }
else
i.tm.opcode_modifier.vex = VEX128;
diff --git a/gas/testsuite/gas/i386/optimize-1.d b/gas/testsuite/gas/i386/optimize-1.d
index 33ce43c..4358c19 100644
--- a/gas/testsuite/gas/i386/optimize-1.d
+++ b/gas/testsuite/gas/i386/optimize-1.d
@@ -58,4 +58,8 @@ Disassembly of section .text:
+[a-f0-9]+: c5 f1 fb e9 vpsubq %xmm1,%xmm1,%xmm5
+[a-f0-9]+: c5 f1 fb e9 vpsubq %xmm1,%xmm1,%xmm5
+[a-f0-9]+: c5 f1 fb e9 vpsubq %xmm1,%xmm1,%xmm5
+ +[a-f0-9]+: c5 f4 47 e9 kxorw %k1,%k1,%k5
+ +[a-f0-9]+: c5 f4 47 e9 kxorw %k1,%k1,%k5
+ +[a-f0-9]+: c5 f4 42 e9 kandnw %k1,%k1,%k5
+ +[a-f0-9]+: c5 f4 42 e9 kandnw %k1,%k1,%k5
#pass
diff --git a/gas/testsuite/gas/i386/optimize-1.s b/gas/testsuite/gas/i386/optimize-1.s
index 21b9594..f61a176 100644
--- a/gas/testsuite/gas/i386/optimize-1.s
+++ b/gas/testsuite/gas/i386/optimize-1.s
@@ -66,3 +66,9 @@ _start:
vpsubq %ymm1, %ymm1, %ymm5{z}{%k7}
vpsubq %zmm1, %zmm1, %zmm5
vpsubq %ymm1, %ymm1, %ymm5
+
+ kxord %k1, %k1, %k5
+ kxorq %k1, %k1, %k5
+
+ kandnd %k1, %k1, %k5
+ kandnq %k1, %k1, %k5
diff --git a/gas/testsuite/gas/i386/optimize-4.d b/gas/testsuite/gas/i386/optimize-4.d
index c9f50f5..9f99dad 100644
--- a/gas/testsuite/gas/i386/optimize-4.d
+++ b/gas/testsuite/gas/i386/optimize-4.d
@@ -58,6 +58,10 @@ Disassembly of section .text:
+[a-f0-9]+: c5 f1 fb e9 vpsubq %xmm1,%xmm1,%xmm5
+[a-f0-9]+: c5 f1 fb e9 vpsubq %xmm1,%xmm1,%xmm5
+[a-f0-9]+: c5 f1 fb e9 vpsubq %xmm1,%xmm1,%xmm5
+ +[a-f0-9]+: c5 f4 47 e9 kxorw %k1,%k1,%k5
+ +[a-f0-9]+: c5 f4 47 e9 kxorw %k1,%k1,%k5
+ +[a-f0-9]+: c5 f4 42 e9 kandnw %k1,%k1,%k5
+ +[a-f0-9]+: c5 f4 42 e9 kandnw %k1,%k1,%k5
+[a-f0-9]+: 62 f1 f5 08 55 e9 vandnpd %xmm1,%xmm1,%xmm5
+[a-f0-9]+: 62 f1 f5 08 55 e9 vandnpd %xmm1,%xmm1,%xmm5
#pass
diff --git a/gas/testsuite/gas/i386/optimize-5.d b/gas/testsuite/gas/i386/optimize-5.d
index ba4601e..cfd0df0 100644
--- a/gas/testsuite/gas/i386/optimize-5.d
+++ b/gas/testsuite/gas/i386/optimize-5.d
@@ -58,6 +58,10 @@ Disassembly of section .text:
+[a-f0-9]+: c5 f1 fb e9 vpsubq %xmm1,%xmm1,%xmm5
+[a-f0-9]+: c5 f1 fb e9 vpsubq %xmm1,%xmm1,%xmm5
+[a-f0-9]+: c5 f1 fb e9 vpsubq %xmm1,%xmm1,%xmm5
+ +[a-f0-9]+: c5 f4 47 e9 kxorw %k1,%k1,%k5
+ +[a-f0-9]+: c5 f4 47 e9 kxorw %k1,%k1,%k5
+ +[a-f0-9]+: c5 f4 42 e9 kandnw %k1,%k1,%k5
+ +[a-f0-9]+: c5 f4 42 e9 kandnw %k1,%k1,%k5
+[a-f0-9]+: 62 f1 f5 08 55 e9 vandnpd %xmm1,%xmm1,%xmm5
+[a-f0-9]+: 62 f1 f5 08 55 e9 vandnpd %xmm1,%xmm1,%xmm5
#pass