aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Beulich <jbeulich@suse.com>2024-06-28 08:24:12 +0200
committerJan Beulich <jbeulich@suse.com>2024-06-28 08:24:12 +0200
commit7add9939175aa71faa37c40dcedcb9190e3b37d8 (patch)
tree49f44324dad8743cdcf29770201016037db5a01d /gas/config/tc-i386.c
parentx86/APX: optimize {nf}-form IMUL-by-power-of-2 to SHL (diff)
downloadbinutils-gdb-7add9939175aa71faa37c40dcedcb9190e3b37d8.tar.gz
binutils-gdb-7add9939175aa71faa37c40dcedcb9190e3b37d8.tar.bz2
binutils-gdb-7add9939175aa71faa37c40dcedcb9190e3b37d8.zip
x86/APX: extend TEST-by-imm7 optimization to CTESTcc
The same properties apply there.
Diffstat (limited to 'gas/config/tc-i386.c')
-rw-r--r--gas/config/tc-i386.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c
index 7ad0267929f..4de5c0127a3 100644
--- a/gas/config/tc-i386.c
+++ b/gas/config/tc-i386.c
@@ -4770,7 +4770,9 @@ optimize_encoding (void)
}
if (optimize_for_space
- && i.tm.mnem_off == MN_test
+ && (i.tm.mnem_off == MN_test
+ || (i.tm.base_opcode == 0xf6
+ && i.tm.opcode_space == SPACE_EVEXMAP4))
&& i.reg_operands == 1
&& i.imm_operands == 1
&& !i.types[1].bitfield.byte
@@ -4779,9 +4781,13 @@ optimize_encoding (void)
&& fits_in_imm7 (i.op[0].imms->X_add_number))
{
/* Optimize: -Os:
- test $imm7, %r64/%r32/%r16 -> test $imm7, %r8
+ test $imm7, %r64/%r32/%r16 -> test $imm7, %r8
+ ctest<cc> $imm7, %r64/%r32/%r16 -> ctest<cc> $imm7, %r8
*/
unsigned int base_regnum = i.op[1].regs->reg_num;
+
+ gas_assert (!i.tm.opcode_modifier.modrm || i.tm.extension_opcode == 0);
+
if (flag_code == CODE_64BIT || base_regnum < 4)
{
i.types[1].bitfield.byte = 1;