diff options
author | Jan Beulich <jbeulich@suse.com> | 2024-01-26 10:31:38 +0100 |
---|---|---|
committer | Jan Beulich <jbeulich@suse.com> | 2024-01-26 10:31:38 +0100 |
commit | 0ebcbb1bd03c4fde91b032b50ec9c3a8f376b8be (patch) | |
tree | 028ab219218cc96320f7d3decb8a68829fd4904e /gas | |
parent | cd35c9fd1e67b2dd8acbda3dfa398e395b22f220 (diff) | |
download | gdb-0ebcbb1bd03c4fde91b032b50ec9c3a8f376b8be.zip gdb-0ebcbb1bd03c4fde91b032b50ec9c3a8f376b8be.tar.gz gdb-0ebcbb1bd03c4fde91b032b50ec9c3a8f376b8be.tar.bz2 |
x86/APX: optimize MOVBE
With identical source and destination it can be covered by the NDD-to-
legacy conversion logic as well, even if in this case the original insn
doesn't use an NDD encoding. The size savings are even better here, for
the replacement (BSWAP) not having a ModR/M byte.
Diffstat (limited to 'gas')
-rw-r--r-- | gas/config/tc-i386.c | 15 | ||||
-rw-r--r-- | gas/testsuite/gas/i386/x86-64-apx-ndd-optimize.d | 3 | ||||
-rw-r--r-- | gas/testsuite/gas/i386/x86-64-apx-ndd-optimize.s | 3 |
3 files changed, 17 insertions, 4 deletions
diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c index 51166ef..3d3d4a3 100644 --- a/gas/config/tc-i386.c +++ b/gas/config/tc-i386.c @@ -8959,10 +8959,11 @@ match_template (char mnem_suffix) if (optimize && !i.no_optimize && i.vec_encoding != vex_encoding_evex - && t + 1 < current_templates.end - && !t[1].opcode_modifier.evex - && t[1].opcode_space <= SPACE_0F38 - && t->opcode_modifier.vexvvvv == VexVVVV_DST + && ((t + 1 < current_templates.end + && !t[1].opcode_modifier.evex + && t[1].opcode_space <= SPACE_0F38 + && t->opcode_modifier.vexvvvv == VexVVVV_DST) + || t->mnem_off == MN_movbe) && (i.types[i.operands - 1].bitfield.dword || i.types[i.operands - 1].bitfield.qword)) { @@ -8999,6 +9000,12 @@ match_template (char mnem_suffix) --i.operands; --i.reg_operands; + if (t->mnem_off == MN_movbe) + { + gas_assert (t[1].mnem_off == MN_bswap); + ++current_templates.end; + } + specific_error = progress (internal_error); continue; } diff --git a/gas/testsuite/gas/i386/x86-64-apx-ndd-optimize.d b/gas/testsuite/gas/i386/x86-64-apx-ndd-optimize.d index 773ceea..8069799 100644 --- a/gas/testsuite/gas/i386/x86-64-apx-ndd-optimize.d +++ b/gas/testsuite/gas/i386/x86-64-apx-ndd-optimize.d @@ -118,6 +118,9 @@ Disassembly of section .text: \s*[a-f0-9]+:\s*67 0f 4d 90 90 90 90 90 cmovge -0x6f6f6f70\(%eax\),%edx \s*[a-f0-9]+:\s*67 0f 4e 90 90 90 90 90 cmovle -0x6f6f6f70\(%eax\),%edx \s*[a-f0-9]+:\s*67 0f 4f 90 90 90 90 90 cmovg -0x6f6f6f70\(%eax\),%edx +\s*[a-f0-9]+:\s*62 f4 7d 08 60 c0 movbe %ax,%ax +\s*[a-f0-9]+:\s*49 0f c8 bswap %r8 +\s*[a-f0-9]+:\s*d5 98 c8 bswap %r16 \s*[a-f0-9]+:\s*66 0f 38 f6 c3 adcx %ebx,%eax \s*[a-f0-9]+:\s*66 0f 38 f6 c3 adcx %ebx,%eax \s*[a-f0-9]+:\s*62 f4 fd 18 66 c3 adcx %rbx,%rax,%rax diff --git a/gas/testsuite/gas/i386/x86-64-apx-ndd-optimize.s b/gas/testsuite/gas/i386/x86-64-apx-ndd-optimize.s index 6ffdf5a..c83e119 100644 --- a/gas/testsuite/gas/i386/x86-64-apx-ndd-optimize.s +++ b/gas/testsuite/gas/i386/x86-64-apx-ndd-optimize.s @@ -111,6 +111,9 @@ cmovl 0x90909090(%eax),%edx,%edx cmovge 0x90909090(%eax),%edx,%edx cmovle 0x90909090(%eax),%edx,%edx cmovg 0x90909090(%eax),%edx,%edx +movbe %ax,%ax +movbe %r8,%r8 +movbe %r16,%r16 adcx %ebx,%eax,%eax adcx %eax,%ebx,%eax adcx %rbx,%rax,%rax |