@@ -6400,6 +6400,58 @@ optimize_nf_encoding (void)
i.types[0].bitfield.imm32 = 0;
i.types[0].bitfield.imm32s = 0;
}
+ else if (optimize_for_space
+ && i.tm.base_opcode == 0x80
+ && (i.tm.extension_opcode == 1 || i.tm.extension_opcode == 6)
+ && 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 <= 0xffff
+ && is_plausible_suffix (1)
+ && (i.types[1].bitfield.qword
+ ? (i.reg_operands == 1
+ || i.op[1].regs == i.op[2].regs)
+ : (i.types[1].bitfield.word
+ && i.reg_operands == 1
+ && i.op[0].imms->X_add_number <= 0xff)))
+ {
+ /* Optimize: -Os:
+ OR one of or / xor:
+ {nf} ORq $imm8, %rN, %rN -> {nf} ORb $imm8, %rN
+ {nf} ORq $imm8, %rN -> {nf} ORb $imm8, %rN
+ {nf} ORw $imm8, %rN -> {nf} ORb $imm8, %rN
+
+ {nf} ORq $imm16, %rN, %rN -> {nf} ORw $imm16, %rN
+ {nf} ORq $imm16, %rN -> {nf} ORw $imm16, %rN
+ */
+ if (i.reg_operands == 2)
+ {
+ i.tm.opcode_modifier.vexvvvv = 0;
+ i.reg_operands = 1;
+ i.operands = 2;
+ }
+
+ if (i.op[0].imms->X_add_number <= 0xff)
+ {
+ i.types[0].bitfield.imm8 = 1;
+ i.types[0].bitfield.imm16 = 0;
+ i.types[1].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
@@ -1488,6 +1488,14 @@ optimize:
{nf} and $~0xaa55, %rcx, %rcx
{nf} and $~0xaa55, %rcx
+ .irp op, or, xor
+ {nf} \op $0xaa, %rcx, %rcx
+ {nf} \op $0xaa, %rcx
+ {nf} \op $0xaa, %cx
+ {nf} \op $0xaa55, %rcx, %rcx
+ {nf} \op $0xaa55, %rcx
+ .endr
+
.irp dir, l, r
{nf} ro\dir $7, %dl
{nf} ro\dir $7, %dl, %al
@@ -1530,6 +1530,16 @@ Disassembly of section \.text:
[ ]*[a-f0-9]+:[ ]*62 f4 7d 0c 81 e1 55 ff[ ]+\{nf\} and \$0xff55,%cx
[ ]*[a-f0-9]+:[ ]*62 f4 f4 1c 81 e1 aa 55 ff ff[ ]+\{nf\} and \$0xf+55aa,%rcx,%rcx
[ ]*[a-f0-9]+:[ ]*62 f4 fc 0c 81 e1 aa 55 ff ff[ ]+\{nf\} and \$0xf+55aa,%rcx
+[ ]*[a-f0-9]+:[ ]*62 f4 f4 1c 81 c9 aa 00 00 00[ ]+\{nf\} or \$0xaa,%rcx,%rcx
+[ ]*[a-f0-9]+:[ ]*62 f4 fc 0c 81 c9 aa 00 00 00[ ]+\{nf\} or \$0xaa,%rcx
+[ ]*[a-f0-9]+:[ ]*62 f4 7d 0c 81 c9 aa 00[ ]+\{nf\} or \$0xaa,%cx
+[ ]*[a-f0-9]+:[ ]*62 f4 f4 1c 81 c9 55 aa 00 00[ ]+\{nf\} or \$0xaa55,%rcx,%rcx
+[ ]*[a-f0-9]+:[ ]*62 f4 fc 0c 81 c9 55 aa 00 00[ ]+\{nf\} or \$0xaa55,%rcx
+[ ]*[a-f0-9]+:[ ]*62 f4 f4 1c 81 f1 aa 00 00 00[ ]+\{nf\} xor \$0xaa,%rcx,%rcx
+[ ]*[a-f0-9]+:[ ]*62 f4 fc 0c 81 f1 aa 00 00 00[ ]+\{nf\} xor \$0xaa,%rcx
+[ ]*[a-f0-9]+:[ ]*62 f4 7d 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-9]+:[ ]*62 f4 7c 0c 80 f1 aa[ ]+\{nf\} xor \$0xaa,%cl
+[ ]*[a-f0-9]+:[ ]*62 f4 7d 0c 81 f1 55 aa[ ]+\{nf\} xor \$0xaa55,%cx
+[ ]*[a-f0-9]+:[ ]*62 f4 7d 0c 81 f1 55 aa[ ]+\{nf\} xor \$0xaa55,%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
@@ -319,7 +319,7 @@ sti, 0xfb, 0, NoSuf, {}
<alu2:opc:c:optz:optt:opti:optiE:nf, +
add:0:C:::::NF|Optimize, +
- or:1:C::Optimize:::NF, +
+ or:1:C::Optimize::Optimize:NF, +
adc:2:C:::::, +
sbb:3::::::, +
and:4:C::Optimize:Optimize:Optimize:NF, +