i386: Also check R12-R15 registers when optimizing testq to testb
authorH.J. Lu <hjl.tools@gmail.com>
Thu, 12 Dec 2019 20:25:48 +0000 (12:25 -0800)
committerH.J. Lu <hjl.tools@gmail.com>
Thu, 12 Dec 2019 20:31:26 +0000 (12:31 -0800)
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.

gas/ChangeLog
gas/config/tc-i386.c
gas/testsuite/gas/i386/x86-64-optimize-3.d
gas/testsuite/gas/i386/x86-64-optimize-3.s
gas/testsuite/gas/i386/x86-64-optimize-3b.d

index 4675ec817697cf38ef709b759fcc45b7acfe40f3..48c5430855ca86c0e14e121575a24d6f6678f138 100644 (file)
@@ -1,3 +1,14 @@
+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.
index 6c71fc4d223b989e6b1bdfe4a5c8906d48aa1ffa..0dc44a89a2e734f0c1640287ca1cf5b72c8260c7 100644 (file)
@@ -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)
index 66ed213b58a55524999bd86d7baa412ed4a23640..26122dd4e1e88565ca41d2f583a0a9db967a531d 100644 (file)
@@ -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
index 45b418a6fd1a38cde3c2a771a7b6831db60174d9..cbfed3bdf471b3f805d945dfc8f9010cf6034686 100644 (file)
@@ -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
index 19ea29ac066206b79eba0b818ae5309244ebc2cb..00b65f3d8b239b5ac53a785b9b99f1dae57ed037 100644 (file)
@@ -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
This page took 0.031731 seconds and 4 git commands to generate.