diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2019-12-12 12:25:48 -0800 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2019-12-12 12:31:26 -0800 |
commit | ac0ab1842de0e4522248ff9805c5c4e3267c8ae7 (patch) | |
tree | d07205df31a85cd5658dec5ff14032bc6174a221 | |
parent | 8493b6651af3d2130d5f5f050905cd3d6e8a9c27 (diff) | |
download | binutils-ac0ab1842de0e4522248ff9805c5c4e3267c8ae7.zip binutils-ac0ab1842de0e4522248ff9805c5c4e3267c8ae7.tar.gz binutils-ac0ab1842de0e4522248ff9805c5c4e3267c8ae7.tar.bz2 |
i386: Also check R12-R15 registers when optimizing testq to testb
Similar to SP, BP, SI and DI registers, R12-R15 registers must use REX
prefix for the low byte register when optimizing
test $imm7, %r64/%r32/%r16 -> test $imm7, %r8
PR gas/25274
* config/tc-i386.c (optimize_encoding): Also check R12-R15
registers for "test $imm7, %r64/%r32/%r16 -> test $imm7, %r8"
optimization.
* testsuite/gas/i386/x86-64-optimize-3.s: Add tests for test
with r12.
* testsuite/gas/i386/x86-64-optimize-3.d: Updated.
* testsuite/gas/i386/x86-64-optimize-3b.d: Likewise.
-rw-r--r-- | gas/ChangeLog | 11 | ||||
-rw-r--r-- | gas/config/tc-i386.c | 5 | ||||
-rw-r--r-- | gas/testsuite/gas/i386/x86-64-optimize-3.d | 4 | ||||
-rw-r--r-- | gas/testsuite/gas/i386/x86-64-optimize-3.s | 4 | ||||
-rw-r--r-- | gas/testsuite/gas/i386/x86-64-optimize-3b.d | 4 |
5 files changed, 25 insertions, 3 deletions
diff --git a/gas/ChangeLog b/gas/ChangeLog index 4675ec8..48c5430 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,5 +1,16 @@ 2019-12-12 H.J. Lu <hongjiu.lu@intel.com> + PR gas/25274 + * config/tc-i386.c (optimize_encoding): Also check R12-R15 + registers for "test $imm7, %r64/%r32/%r16 -> test $imm7, %r8" + optimization. + * testsuite/gas/i386/x86-64-optimize-3.s: Add tests for test + with r12. + * testsuite/gas/i386/x86-64-optimize-3.d: Updated. + * testsuite/gas/i386/x86-64-optimize-3b.d: Likewise. + +2019-12-12 H.J. Lu <hongjiu.lu@intel.com> + * testsuite/gas/i386/align-branch-1.s: New file. * testsuite/gas/i386/align-branch-1a.d: Likewise. * testsuite/gas/i386/align-branch-1b.d: Likewise. diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c index 6c71fc4..0dc44a8 100644 --- a/gas/config/tc-i386.c +++ b/gas/config/tc-i386.c @@ -4008,10 +4008,9 @@ optimize_encoding (void) i.types[1].bitfield.byte = 1; /* Ignore the suffix. */ i.suffix = 0; - if (base_regnum >= 4 - && !(i.op[1].regs->reg_flags & RegRex)) + if (base_regnum >= 4) { - /* Handle SP, BP, SI and DI registers. */ + /* Handle SP, BP, SI, DI and R12-R15 registers. */ if (i.types[1].bitfield.word) j = 16; else if (i.types[1].bitfield.dword) diff --git a/gas/testsuite/gas/i386/x86-64-optimize-3.d b/gas/testsuite/gas/i386/x86-64-optimize-3.d index 66ed213..26122dd 100644 --- a/gas/testsuite/gas/i386/x86-64-optimize-3.d +++ b/gas/testsuite/gas/i386/x86-64-optimize-3.d @@ -24,6 +24,10 @@ Disassembly of section .text: +[a-f0-9]+: 41 f6 c1 7f test \$0x7f,%r9b +[a-f0-9]+: 41 f6 c1 7f test \$0x7f,%r9b +[a-f0-9]+: 41 f6 c1 7f test \$0x7f,%r9b + +[a-f0-9]+: 41 f6 c4 7f test \$0x7f,%r12b + +[a-f0-9]+: 41 f6 c4 7f test \$0x7f,%r12b + +[a-f0-9]+: 41 f6 c4 7f test \$0x7f,%r12b + +[a-f0-9]+: 41 f6 c4 7f test \$0x7f,%r12b +[a-f0-9]+: 20 c9 and %cl,%cl +[a-f0-9]+: 66 21 d2 and %dx,%dx +[a-f0-9]+: 21 db and %ebx,%ebx diff --git a/gas/testsuite/gas/i386/x86-64-optimize-3.s b/gas/testsuite/gas/i386/x86-64-optimize-3.s index 45b418a..cbfed3b 100644 --- a/gas/testsuite/gas/i386/x86-64-optimize-3.s +++ b/gas/testsuite/gas/i386/x86-64-optimize-3.s @@ -19,6 +19,10 @@ _start: test $0x7f, %r9d test $0x7f, %r9w test $0x7f, %r9b + test $0x7f, %r12 + test $0x7f, %r12d + test $0x7f, %r12w + test $0x7f, %r12b and %cl, %cl and %dx, %dx diff --git a/gas/testsuite/gas/i386/x86-64-optimize-3b.d b/gas/testsuite/gas/i386/x86-64-optimize-3b.d index 19ea29a..00b65f3 100644 --- a/gas/testsuite/gas/i386/x86-64-optimize-3b.d +++ b/gas/testsuite/gas/i386/x86-64-optimize-3b.d @@ -25,6 +25,10 @@ Disassembly of section .text: +[a-f0-9]+: 41 f7 c1 7f 00 00 00 test \$0x7f,%r9d +[a-f0-9]+: 66 41 f7 c1 7f 00 test \$0x7f,%r9w +[a-f0-9]+: 41 f6 c1 7f test \$0x7f,%r9b + +[a-f0-9]+: 41 f7 c4 7f 00 00 00 test \$0x7f,%r12d + +[a-f0-9]+: 41 f7 c4 7f 00 00 00 test \$0x7f,%r12d + +[a-f0-9]+: 66 41 f7 c4 7f 00 test \$0x7f,%r12w + +[a-f0-9]+: 41 f6 c4 7f test \$0x7f,%r12b +[a-f0-9]+: 84 c9 test %cl,%cl +[a-f0-9]+: 66 85 d2 test %dx,%dx +[a-f0-9]+: 21 db and %ebx,%ebx |