@@ -6293,6 +6293,62 @@ optimize_nf_encoding (void)
i.operands = 2;
i.reg_operands = i.operands - i.mem_operands;
}
+ else if (i.tm.base_opcode == 0x80
+ && i.tm.extension_opcode == 4
+ && i.reg_operands + 1 == i.operands
+ && !i.prefix[DATA_PREFIX]
+ && !i.prefix[REX_PREFIX]
+ && i.op[0].imms->X_op == O_constant
+ && i.op[0].imms->X_add_number >= 0
+ && i.op[0].imms->X_add_number <= (optimize_for_space ? 0xffff : 0xff)
+ && is_plausible_suffix (1)
+ && !i.types[1].bitfield.byte
+ && (!i.types[1].bitfield.word
+ || (i.reg_operands == 2
+ && i.op[0].imms->X_add_number <= 0xff)))
+ {
+ /* Optimize: -O:
+ {nf} andq $imm8, %rN, %rM -> {nf} andb $imm8, %rN, %rM
+ {nf} andl $imm8, %rN, %rM -> {nf} andb $imm8, %rN, %rM
+ {nf} andw $imm8, %rN, %rM -> {nf} andb $imm8, %rN, %rM
+
+ {nf} andq $imm8, %rN -> {nf} andb $imm8, %rN, %rN
+ {nf} andl $imm8, %rN -> {nf} andb $imm8, %rN, %rN
+
+ Optimize: -Os:
+ {nf} andq $imm16, %rN, %rM -> {nf} andw $imm16, %rN, %rM
+ {nf} andl $imm16, %rN, %rM -> {nf} andw $imm16, %rN, %rM
+
+ {nf} andq $imm16, %rN -> {nf} andw $imm16, %rN, %rN
+ {nf} andl $imm16, %rN -> {nf} andw $imm16, %rN, %rN
+ */
+ if (i.reg_operands == 1)
+ {
+ copy_operand (2, 1);
+ i.tm.opcode_modifier.vexvvvv = VexVVVV_DST;
+ i.reg_operands = 2;
+ i.operands = 3;
+ }
+
+ if (i.op[0].imms->X_add_number <= 0xff)
+ {
+ i.types[0].bitfield.imm8 = 1;
+ i.types[0].bitfield.imm16 = 0;
+ i.types[2].bitfield.byte = 1;
+ i.suffix = 0;
+ i.tm.opcode_modifier.w = 0;
+ i.tm.opcode_modifier.vexw = VEXWIG;
+ }
+ else
+ {
+ i.types[0].bitfield.imm16 = 1;
+ i.tm.opcode_modifier.size = SIZE16;
+ i.tm.opcode_modifier.vexw = VEXW0;
+ }
+
+ i.types[0].bitfield.imm32 = 0;
+ i.types[0].bitfield.imm32s = 0;
+ }
else if (i.tm.base_opcode == 0xc0
&& i.op[0].imms->X_op == O_constant
&& i.op[0].imms->X_add_number
@@ -1472,6 +1472,16 @@ optimize:
{nf} imul $-1, (%rax), %ecx
{nf} imul $-1, (%rax), %r9
+ {nf} and $0xaa, %rcx, %rdx
+ {nf} and $0xaa, %ecx, %edx
+ {nf} and $0xaa, %cx, %dx
+ {nf} and $0xaa, %rcx
+ {nf} and $0xaa, %ecx
+ {nf} and $0xaa55, %rcx, %rdx
+ {nf} and $0xaa55, %ecx, %edx
+ {nf} and $0xaa55, %rcx
+ {nf} and $0xaa55, %ecx
+
.irp dir, l, r
{nf} ro\dir $7, %dl
{nf} ro\dir $7, %dl, %al
@@ -1516,6 +1516,15 @@ Disassembly of section \.text:
[ ]*[a-f0-9]+:[ ]*62 f4 65 1c f7 18[ ]+\{nf\} neg \(%rax\),%bx
[ ]*[a-f0-9]+:[ ]*62 f4 74 1c f7 18[ ]+\{nf\} neg \(%rax\),%ecx
[ ]*[a-f0-9]+:[ ]*62 f4 b4 1c f7 18[ ]+\{nf\} neg \(%rax\),%r9
+[ ]*[a-f0-9]+:[ ]*62 f4 6c 1c 80 e1 aa[ ]+\{nf\} and \$0xaa,%cl,%dl
+[ ]*[a-f0-9]+:[ ]*62 f4 6c 1c 80 e1 aa[ ]+\{nf\} and \$0xaa,%cl,%dl
+[ ]*[a-f0-9]+:[ ]*62 f4 6c 1c 80 e1 aa[ ]+\{nf\} and \$0xaa,%cl,%dl
+[ ]*[a-f0-9]+:[ ]*62 f4 74 1c 80 e1 aa[ ]+\{nf\} and \$0xaa,%cl,%cl
+[ ]*[a-f0-9]+:[ ]*62 f4 74 1c 80 e1 aa[ ]+\{nf\} and \$0xaa,%cl,%cl
+[ ]*[a-f0-9]+:[ ]*62 f4 ec 1c 81 e1 55 a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]*[a-f0-9]+:[ ]*62 f4 6d 1c 81 e1 55 aa[ ]+\{nf\} and \$0xaa55,%cx,%dx
+[ ]*[a-f0-9]+:[ ]*62 f4 75 1c 81 e1 55 aa[ ]+\{nf\} and \$0xaa55,%cx,%cx
+[ ]*[a-f0-9]+:[ ]*62 f4 75 1c 81 e1 55 aa[ ]+\{nf\} and \$0xaa55,%cx,%cx
[ ]*[a-f0-9]+:[ ]*62 f4 7c 0c d0 ca[ ]+\{nf\} ror \$1,%dl
[ ]*[a-f0-9]+:[ ]*62 f4 7c 1c d0 ca[ ]+\{nf\} ror \$1,%dl,%al
[ ]*[a-f0-9]+:[ ]*62 f4 7d 0c d1 ca[ ]+\{nf\} ror \$1,%dx
@@ -322,7 +322,7 @@ sti, 0xfb, 0, NoSuf, {}
or:1:C::Optimize:::NF, +
adc:2:C:::::, +
sbb:3::::::, +
- and:4:C::Optimize:Optimize::NF, +
+ and:4:C::Optimize:Optimize:Optimize:NF, +
sub:5::Optimize:::Optimize:NF, +
xor:6:C:Optimize:::Optimize:NF>