diff options
author | Jan Beulich <jbeulich@suse.com> | 2024-06-28 08:19:32 +0200 |
---|---|---|
committer | Jan Beulich <jbeulich@suse.com> | 2024-06-28 08:19:32 +0200 |
commit | c7eae03eab750f93b6460e883f25b71d46dd1c47 (patch) | |
tree | 66525e230d31b82444d94c01410f45bec81e6a2a /gas/config/tc-i386.c | |
parent | 0868b8999bbca960781e7d8bbbc363536193a694 (diff) | |
download | binutils-c7eae03eab750f93b6460e883f25b71d46dd1c47.zip binutils-c7eae03eab750f93b6460e883f25b71d46dd1c47.tar.gz binutils-c7eae03eab750f93b6460e883f25b71d46dd1c47.tar.bz2 |
x86/APX: optimize {nf}-form rotate-by-width-less-1
Unlike for the legacy forms, where there's a difference in the resulting
EFLAGS.CF, for the NF variants the immediate can be got rid of in that
case by switching to a 1-bit rotate in the opposite direction.
Diffstat (limited to 'gas/config/tc-i386.c')
-rw-r--r-- | gas/config/tc-i386.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c index c51402a..7ffacf7 100644 --- a/gas/config/tc-i386.c +++ b/gas/config/tc-i386.c @@ -4927,6 +4927,7 @@ optimize_encoding (void) } else if (!optimize_for_space && i.tm.base_opcode == 0xd0 + && i.tm.extension_opcode == 4 && (i.tm.opcode_space == SPACE_BASE || i.tm.opcode_space == SPACE_EVEXMAP4) && !i.mem_operands) @@ -4942,7 +4943,6 @@ optimize_encoding (void) shll $1, %rN, %rM -> addl %rN, %rN, %rM shlq $1, %rN, %rM -> addq %rN, %rN, %rM */ - gas_assert (i.tm.extension_opcode == 4); i.tm.base_opcode = 0x00; i.tm.extension_opcode = None; if (i.operands >= 2) @@ -5403,6 +5403,26 @@ optimize_nf_encoding (void) i.imm_operands = 0; --i.operands; } + else if (i.tm.base_opcode == 0xc0 + && i.op[0].imms->X_op == O_constant + && i.op[0].imms->X_add_number + == (i.types[i.operands - 1].bitfield.byte + || i.suffix == BYTE_MNEM_SUFFIX + ? 7 : i.types[i.operands - 1].bitfield.word + || i.suffix == WORD_MNEM_SUFFIX + ? 15 : 63 >> (i.types[i.operands - 1].bitfield.dword + || i.suffix == LONG_MNEM_SUFFIX))) + { + /* Optimize: -O: + {nf} rol $osz-1, ... -> {nf} ror $1, ... + {nf} ror $osz-1, ... -> {nf} rol $1, ... + */ + gas_assert (i.tm.extension_opcode <= 1); + i.tm.extension_opcode ^= 1; + i.tm.base_opcode = 0xd0; + i.tm.operand_types[0].bitfield.imm1 = 1; + i.imm_operands = 0; + } } static void |