GNU Binutils with patches for OS216
Revision | d3d50934a9101416c3106497d6ea9ce548760253 (tree) |
---|---|
Time | 2018-03-08 23:41:34 |
Author | H.J. Lu <hjl.tools@gmai...> |
Commiter | H.J. Lu |
x86-64: Also optimize "clr reg64"
"clr reg" is an alias of "xor reg, reg". We can encode "clr reg64" as
"xor reg32, reg32".
gas/
* config/tc-i386.c (optimize_encoding): Also encode "clr reg64"
as "xor reg32, reg32".
* testsuite/gas/i386/x86-64-optimize-1.s: Add "clr reg64" tests.
* testsuite/gas/i386/x86-64-optimize-1.d: Updated.
opcodes/
* i386-opc.tbl: Add Optimize to clr.
* i386-tbl.h: Regenerated.
@@ -1,5 +1,12 @@ | ||
1 | 1 | 2018-03-08 H.J. Lu <hongjiu.lu@intel.com> |
2 | 2 | |
3 | + * config/tc-i386.c (optimize_encoding): Also encode "clr reg64" | |
4 | + as "xor reg32, reg32". | |
5 | + * testsuite/gas/i386/x86-64-optimize-1.s: Add "clr reg64" tests. | |
6 | + * testsuite/gas/i386/x86-64-optimize-1.d: Updated. | |
7 | + | |
8 | +2018-03-08 H.J. Lu <hongjiu.lu@intel.com> | |
9 | + | |
3 | 10 | * NEWS: Mention -mold-gcc removal. |
4 | 11 | * config/tc-i386.c (i386_error): Remove old_gcc_only. |
5 | 12 | (old_gcc): Removed. |
@@ -3801,7 +3801,8 @@ optimize_encoding (void) | ||
3801 | 3801 | } |
3802 | 3802 | } |
3803 | 3803 | else if (flag_code == CODE_64BIT |
3804 | - && ((i.reg_operands == 1 | |
3804 | + && ((i.types[1].bitfield.qword | |
3805 | + && i.reg_operands == 1 | |
3805 | 3806 | && i.imm_operands == 1 |
3806 | 3807 | && i.op[0].imms->X_op == O_constant |
3807 | 3808 | && ((i.tm.base_opcode == 0xb0 |
@@ -3816,12 +3817,16 @@ optimize_encoding (void) | ||
3816 | 3817 | || ((i.tm.base_opcode == 0xf6 |
3817 | 3818 | || i.tm.base_opcode == 0xc6) |
3818 | 3819 | && i.tm.extension_opcode == 0x0))))) |
3819 | - || (i.reg_operands == 2 | |
3820 | - && i.op[0].regs == i.op[1].regs | |
3821 | - && ((i.tm.base_opcode == 0x30 | |
3822 | - || i.tm.base_opcode == 0x28) | |
3823 | - && i.tm.extension_opcode == None))) | |
3824 | - && i.types[1].bitfield.qword) | |
3820 | + || (i.types[0].bitfield.qword | |
3821 | + && ((i.reg_operands == 2 | |
3822 | + && i.op[0].regs == i.op[1].regs | |
3823 | + && ((i.tm.base_opcode == 0x30 | |
3824 | + || i.tm.base_opcode == 0x28) | |
3825 | + && i.tm.extension_opcode == None)) | |
3826 | + || (i.reg_operands == 1 | |
3827 | + && i.operands == 1 | |
3828 | + && i.tm.base_opcode == 0x30 | |
3829 | + && i.tm.extension_opcode == None))))) | |
3825 | 3830 | { |
3826 | 3831 | /* Optimize: -O: |
3827 | 3832 | andq $imm31, %r64 -> andl $imm31, %r32 |
@@ -50,4 +50,6 @@ Disassembly of section .text: | ||
50 | 50 | +[a-f0-9]+: b8 ff 03 00 00 mov \$0x3ff,%eax |
51 | 51 | +[a-f0-9]+: 48 b8 00 00 00 00 01 00 00 00 movabs \$0x100000000,%rax |
52 | 52 | +[a-f0-9]+: 48 b8 00 00 00 00 01 00 00 00 movabs \$0x100000000,%rax |
53 | + +[a-f0-9]+: 31 c0 xor %eax,%eax | |
54 | + +[a-f0-9]+: 45 31 f6 xor %r14d,%r14d | |
53 | 55 | #pass |
@@ -45,3 +45,5 @@ _start: | ||
45 | 45 | movq $1023,%rax |
46 | 46 | mov $0x100000000,%rax |
47 | 47 | movq $0x100000000,%rax |
48 | + clrq %rax | |
49 | + clrq %r14 |
@@ -1,5 +1,10 @@ | ||
1 | 1 | 2018-03-08 H.J. Lu <hongjiu.lu@intel.com> |
2 | 2 | |
3 | + * i386-opc.tbl: Add Optimize to clr. | |
4 | + * i386-tbl.h: Regenerated. | |
5 | + | |
6 | +2018-03-08 H.J. Lu <hongjiu.lu@intel.com> | |
7 | + | |
3 | 8 | * i386-gen.c (opcode_modifiers): Remove OldGcc. |
4 | 9 | * i386-opc.h (OldGcc): Removed. |
5 | 10 | (i386_opcode_modifier): Remove oldgcc. |
@@ -205,7 +205,7 @@ xor, 2, 0x34, None, 1, 0, W|No_sSuf|No_ldSuf, { Imm8|Imm16|Imm32|Imm32S, Acc|Byt | ||
205 | 205 | xor, 2, 0x80, 0x6, 1, 0, W|Modrm|No_sSuf|No_ldSuf|IsLockable|HLEPrefixOk, { Imm8|Imm16|Imm32|Imm32S, Reg8|Reg16|Reg32|Reg64|Byte|Word|Dword|Qword|Unspecified|BaseIndex } |
206 | 206 | |
207 | 207 | // clr with 1 operand is really xor with 2 operands. |
208 | -clr, 1, 0x30, None, 1, 0, W|Modrm|No_sSuf|No_ldSuf|RegKludge, { Reg8|Reg16|Reg32|Reg64 } | |
208 | +clr, 1, 0x30, None, 1, 0, W|Modrm|No_sSuf|No_ldSuf|RegKludge|Optimize, { Reg8|Reg16|Reg32|Reg64 } | |
209 | 209 | |
210 | 210 | adc, 2, 0x10, None, 1, 0, D|W|CheckRegSize|Modrm|No_sSuf|No_ldSuf|IsLockable|HLEPrefixOk, { Reg8|Reg16|Reg32|Reg64, Reg8|Reg16|Reg32|Reg64|Byte|Word|Dword|Qword|Unspecified|BaseIndex } |
211 | 211 | adc, 2, 0x83, 0x2, 1, 0, Modrm|No_bSuf|No_sSuf|No_ldSuf|IsLockable|HLEPrefixOk, { Imm8S, Reg16|Reg32|Reg64|Word|Dword|Qword|Unspecified|BaseIndex } |
@@ -2115,7 +2115,7 @@ const insn_template i386_optab[] = | ||
2115 | 2115 | 0, 0, 0, 0, 0, 0 } }, |
2116 | 2116 | { 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
2117 | 2117 | 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
2118 | - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |
2118 | + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, | |
2119 | 2119 | 0, 0, 0, 0 }, |
2120 | 2120 | { { { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
2121 | 2121 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, |