+2017-09-09  H.J. Lu  <hongjiu.lu@intel.com>
+
+       * config/tc-i386.c (NOTRACK_PREFIX): Removed.
+       (REX_PREFIX): Updated.
+       (MAX_PREFIXES): Likewise.
+       (parse_insn): Remove restriction on NOTRACK prefix position.
+       * testsuite/gas/i386/notrack.s: Add tests with NOTRACK prefix
+       before other prefixes.
+       * testsuite/gas/i386/x86-64-notrack.s: Likewise.
+       * testsuite/gas/i386/notrackbad.s: Remove tests with NOTRACK
+       prefix before other prefixes.
+       * testsuite/gas/i386/x86-64-notrackbad.s: Likewise.
+       * testsuite/gas/i386/notrack-intel.d: Updated.
+       * testsuite/gas/i386/notrack.d: Likewise.
+       * testsuite/gas/i386/notrackbad.l: Likewise.
+       * testsuite/gas/i386/x86-64-notrack-intel.d: Likewise.
+       * testsuite/gas/i386/x86-64-notrack.d: Likewise.
+       * testsuite/gas/i386/x86-64-notrackbad.l: Likewise.
+
 2017-09-07  Palmer Dabbelt  <palmer@dabbelt.com>
 
        * config/tc-riscv.c (riscv_frag_align_code): Emit the entire
 
 #define HLE_PREFIX     REP_PREFIX
 #define BND_PREFIX     REP_PREFIX
 #define LOCK_PREFIX    5
-/* Only one of NOTRACK_PREFIX and SEG_PREFIX can be used at the same
-   time.  */
-#define NOTRACK_PREFIX 6
-#define REX_PREFIX     7       /* must come last.  */
-#define MAX_PREFIXES   8       /* max prefixes per opcode */
+#define REX_PREFIX     6       /* must come last.  */
+#define MAX_PREFIXES   7       /* max prefixes per opcode */
 
 /* we define the syntax here (modulo base,index,scale syntax) */
 #define REGISTER_PREFIX '%'
          else
            {
              /* Add prefix, checking for repeated prefixes.  */
-             enum PREFIX_GROUP p
-               = add_prefix (current_templates->start->base_opcode);
-             if (p == PREFIX_DS
-                 && current_templates->start->cpu_flags.bitfield.cpucet)
+             switch (add_prefix (current_templates->start->base_opcode))
                {
-                 i.notrack_prefix = current_templates->start->name;
-                 /* Move NOTRACK_PREFIX_OPCODE to NOTRACK_PREFIX slot so
-                    that it is placed before others.  */
-                 i.prefix[SEG_PREFIX] = 0;
-                 i.prefix[NOTRACK_PREFIX] = NOTRACK_PREFIX_OPCODE;
-               }
-             else
-               {
-                 switch (p)
-                   {
-                   case PREFIX_EXIST:
-                     return NULL;
-                   case PREFIX_REP:
-                     if (current_templates->start->cpu_flags.bitfield.cpuhle)
-                       i.hle_prefix = current_templates->start->name;
-                     else if (current_templates->start->cpu_flags.bitfield.cpumpx)
-                       i.bnd_prefix = current_templates->start->name;
-                     else
-                       i.rep_prefix = current_templates->start->name;
-                     break;
-                   default:
-                     break;
-                   }
-
-                 if (i.notrack_prefix != NULL)
-                   {
-                     /* There must be no other prefixes after NOTRACK
-                        prefix.  */
-                     as_bad (_("expecting no other prefixes after `notrack'"));
-                     return NULL;
-                   }
+               case PREFIX_EXIST:
+                 return NULL;
+               case PREFIX_DS:
+                 if (current_templates->start->cpu_flags.bitfield.cpucet)
+                   i.notrack_prefix = current_templates->start->name;
+                 break;
+               case PREFIX_REP:
+                 if (current_templates->start->cpu_flags.bitfield.cpuhle)
+                   i.hle_prefix = current_templates->start->name;
+                 else if (current_templates->start->cpu_flags.bitfield.cpumpx)
+                   i.bnd_prefix = current_templates->start->name;
+                 else
+                   i.rep_prefix = current_templates->start->name;
+                 break;
+               default:
+                 break;
                }
            }
          /* Skip past PREFIX_SEPARATOR and reset token_start.  */
 
 
 0+ <_start>:
 [      ]*[a-f0-9]+:    3e ff d0                notrack call eax
-[      ]*[a-f0-9]+:    66 3e ff d0             notrack call ax
+[      ]*[a-f0-9]+:    3e 66 ff d0             notrack call ax
 [      ]*[a-f0-9]+:    3e ff e0                notrack jmp eax
-[      ]*[a-f0-9]+:    66 3e ff e0             notrack jmp ax
+[      ]*[a-f0-9]+:    3e 66 ff e0             notrack jmp ax
 [      ]*[a-f0-9]+:    3e ff 10                notrack call DWORD PTR \[eax\]
-[      ]*[a-f0-9]+:    66 3e ff 10             notrack call WORD PTR \[eax\]
+[      ]*[a-f0-9]+:    3e 66 ff 10             notrack call WORD PTR \[eax\]
 [      ]*[a-f0-9]+:    3e ff 20                notrack jmp DWORD PTR \[eax\]
-[      ]*[a-f0-9]+:    66 3e ff 20             notrack jmp WORD PTR \[eax\]
-[      ]*[a-f0-9]+:    f2 3e ff d0             bnd notrack call eax
-[      ]*[a-f0-9]+:    66 f2 3e ff d0          bnd notrack call ax
-[      ]*[a-f0-9]+:    f2 3e ff e0             bnd notrack jmp eax
-[      ]*[a-f0-9]+:    66 f2 3e ff e0          bnd notrack jmp ax
-[      ]*[a-f0-9]+:    f2 3e ff 10             bnd notrack call DWORD PTR \[eax\]
-[      ]*[a-f0-9]+:    66 f2 3e ff 10          bnd notrack call WORD PTR \[eax\]
-[      ]*[a-f0-9]+:    f2 3e ff 20             bnd notrack jmp DWORD PTR \[eax\]
-[      ]*[a-f0-9]+:    66 f2 3e ff 20          bnd notrack jmp WORD PTR \[eax\]
+[      ]*[a-f0-9]+:    3e 66 ff 20             notrack jmp WORD PTR \[eax\]
+[      ]*[a-f0-9]+:    3e f2 ff d0             notrack bnd call eax
+[      ]*[a-f0-9]+:    3e 66 f2 ff d0          notrack bnd call ax
+[      ]*[a-f0-9]+:    3e f2 ff e0             notrack bnd jmp eax
+[      ]*[a-f0-9]+:    3e 66 f2 ff e0          notrack bnd jmp ax
+[      ]*[a-f0-9]+:    3e f2 ff 10             notrack bnd call DWORD PTR \[eax\]
+[      ]*[a-f0-9]+:    3e 66 f2 ff 10          notrack bnd call WORD PTR \[eax\]
+[      ]*[a-f0-9]+:    3e f2 ff 20             notrack bnd jmp DWORD PTR \[eax\]
+[      ]*[a-f0-9]+:    3e 66 f2 ff 20          notrack bnd jmp WORD PTR \[eax\]
+[      ]*[a-f0-9]+:    3e f2 ff d0             notrack bnd call eax
+[      ]*[a-f0-9]+:    3e 66 f2 ff d0          notrack bnd call ax
+[      ]*[a-f0-9]+:    3e f2 ff 10             notrack bnd call DWORD PTR \[eax\]
+[      ]*[a-f0-9]+:    3e 66 f2 ff 10          notrack bnd call WORD PTR \[eax\]
 [      ]*[a-f0-9]+:    3e ff d0                notrack call eax
-[      ]*[a-f0-9]+:    66 3e ff d0             notrack call ax
+[      ]*[a-f0-9]+:    3e 66 ff d0             notrack call ax
 [      ]*[a-f0-9]+:    3e ff e0                notrack jmp eax
-[      ]*[a-f0-9]+:    66 3e ff e0             notrack jmp ax
+[      ]*[a-f0-9]+:    3e 66 ff e0             notrack jmp ax
 [      ]*[a-f0-9]+:    3e ff 10                notrack call DWORD PTR \[eax\]
-[      ]*[a-f0-9]+:    66 3e ff 10             notrack call WORD PTR \[eax\]
+[      ]*[a-f0-9]+:    3e 66 ff 10             notrack call WORD PTR \[eax\]
 [      ]*[a-f0-9]+:    3e ff 20                notrack jmp DWORD PTR \[eax\]
-[      ]*[a-f0-9]+:    66 3e ff 20             notrack jmp WORD PTR \[eax\]
+[      ]*[a-f0-9]+:    3e 66 ff 20             notrack jmp WORD PTR \[eax\]
+[      ]*[a-f0-9]+:    3e f2 ff d0             notrack bnd call eax
+[      ]*[a-f0-9]+:    3e 66 f2 ff d0          notrack bnd call ax
+[      ]*[a-f0-9]+:    3e f2 ff e0             notrack bnd jmp eax
+[      ]*[a-f0-9]+:    3e 66 f2 ff e0          notrack bnd jmp ax
+[      ]*[a-f0-9]+:    3e f2 ff 10             notrack bnd call DWORD PTR \[eax\]
+[      ]*[a-f0-9]+:    3e 66 f2 ff 10          notrack bnd call WORD PTR \[eax\]
+[      ]*[a-f0-9]+:    3e f2 ff 20             notrack bnd jmp DWORD PTR \[eax\]
+[      ]*[a-f0-9]+:    3e 66 f2 ff 20          notrack bnd jmp WORD PTR \[eax\]
+[      ]*[a-f0-9]+:    3e f2 ff d0             notrack bnd call eax
+[      ]*[a-f0-9]+:    3e 66 f2 ff d0          notrack bnd call ax
+[      ]*[a-f0-9]+:    3e f2 ff 10             notrack bnd call DWORD PTR \[eax\]
+[      ]*[a-f0-9]+:    3e 66 f2 ff 10          notrack bnd call WORD PTR \[eax\]
 [      ]*[a-f0-9]+:    f2 3e ff d0             bnd notrack call eax
-[      ]*[a-f0-9]+:    66 f2 3e ff d0          bnd notrack call ax
-[      ]*[a-f0-9]+:    f2 3e ff e0             bnd notrack jmp eax
-[      ]*[a-f0-9]+:    66 f2 3e ff e0          bnd notrack jmp ax
-[      ]*[a-f0-9]+:    f2 3e ff 10             bnd notrack call DWORD PTR \[eax\]
-[      ]*[a-f0-9]+:    66 f2 3e ff 10          bnd notrack call WORD PTR \[eax\]
-[      ]*[a-f0-9]+:    f2 3e ff 20             bnd notrack jmp DWORD PTR \[eax\]
-[      ]*[a-f0-9]+:    66 f2 3e ff 20          bnd notrack jmp WORD PTR \[eax\]
-[      ]*[a-f0-9]+:    3e f2 ff d0             ds bnd call eax
-[      ]*[a-f0-9]+:    3e 66 ff d0             ds call ax
+[      ]*[a-f0-9]+:    66 3e ff d0             notrack call ax
 #pass
 
 
 0+ <_start>:
 [      ]*[a-f0-9]+:    3e ff d0                notrack call \*%eax
-[      ]*[a-f0-9]+:    66 3e ff d0             notrack callw \*%ax
+[      ]*[a-f0-9]+:    3e 66 ff d0             notrack callw \*%ax
 [      ]*[a-f0-9]+:    3e ff e0                notrack jmp \*%eax
-[      ]*[a-f0-9]+:    66 3e ff e0             notrack jmpw \*%ax
+[      ]*[a-f0-9]+:    3e 66 ff e0             notrack jmpw \*%ax
 [      ]*[a-f0-9]+:    3e ff 10                notrack call \*\(%eax\)
-[      ]*[a-f0-9]+:    66 3e ff 10             notrack callw \*\(%eax\)
+[      ]*[a-f0-9]+:    3e 66 ff 10             notrack callw \*\(%eax\)
 [      ]*[a-f0-9]+:    3e ff 20                notrack jmp \*\(%eax\)
-[      ]*[a-f0-9]+:    66 3e ff 20             notrack jmpw \*\(%eax\)
-[      ]*[a-f0-9]+:    f2 3e ff d0             bnd notrack call \*%eax
-[      ]*[a-f0-9]+:    66 f2 3e ff d0          bnd notrack callw \*%ax
-[      ]*[a-f0-9]+:    f2 3e ff e0             bnd notrack jmp \*%eax
-[      ]*[a-f0-9]+:    66 f2 3e ff e0          bnd notrack jmpw \*%ax
-[      ]*[a-f0-9]+:    f2 3e ff 10             bnd notrack call \*\(%eax\)
-[      ]*[a-f0-9]+:    66 f2 3e ff 10          bnd notrack callw \*\(%eax\)
-[      ]*[a-f0-9]+:    f2 3e ff 20             bnd notrack jmp \*\(%eax\)
-[      ]*[a-f0-9]+:    66 f2 3e ff 20          bnd notrack jmpw \*\(%eax\)
+[      ]*[a-f0-9]+:    3e 66 ff 20             notrack jmpw \*\(%eax\)
+[      ]*[a-f0-9]+:    3e f2 ff d0             notrack bnd call \*%eax
+[      ]*[a-f0-9]+:    3e 66 f2 ff d0          notrack bnd callw \*%ax
+[      ]*[a-f0-9]+:    3e f2 ff e0             notrack bnd jmp \*%eax
+[      ]*[a-f0-9]+:    3e 66 f2 ff e0          notrack bnd jmpw \*%ax
+[      ]*[a-f0-9]+:    3e f2 ff 10             notrack bnd call \*\(%eax\)
+[      ]*[a-f0-9]+:    3e 66 f2 ff 10          notrack bnd callw \*\(%eax\)
+[      ]*[a-f0-9]+:    3e f2 ff 20             notrack bnd jmp \*\(%eax\)
+[      ]*[a-f0-9]+:    3e 66 f2 ff 20          notrack bnd jmpw \*\(%eax\)
+[      ]*[a-f0-9]+:    3e f2 ff d0             notrack bnd call \*%eax
+[      ]*[a-f0-9]+:    3e 66 f2 ff d0          notrack bnd callw \*%ax
+[      ]*[a-f0-9]+:    3e f2 ff 10             notrack bnd call \*\(%eax\)
+[      ]*[a-f0-9]+:    3e 66 f2 ff 10          notrack bnd callw \*\(%eax\)
 [      ]*[a-f0-9]+:    3e ff d0                notrack call \*%eax
-[      ]*[a-f0-9]+:    66 3e ff d0             notrack callw \*%ax
+[      ]*[a-f0-9]+:    3e 66 ff d0             notrack callw \*%ax
 [      ]*[a-f0-9]+:    3e ff e0                notrack jmp \*%eax
-[      ]*[a-f0-9]+:    66 3e ff e0             notrack jmpw \*%ax
+[      ]*[a-f0-9]+:    3e 66 ff e0             notrack jmpw \*%ax
 [      ]*[a-f0-9]+:    3e ff 10                notrack call \*\(%eax\)
-[      ]*[a-f0-9]+:    66 3e ff 10             notrack callw \*\(%eax\)
+[      ]*[a-f0-9]+:    3e 66 ff 10             notrack callw \*\(%eax\)
 [      ]*[a-f0-9]+:    3e ff 20                notrack jmp \*\(%eax\)
-[      ]*[a-f0-9]+:    66 3e ff 20             notrack jmpw \*\(%eax\)
+[      ]*[a-f0-9]+:    3e 66 ff 20             notrack jmpw \*\(%eax\)
+[      ]*[a-f0-9]+:    3e f2 ff d0             notrack bnd call \*%eax
+[      ]*[a-f0-9]+:    3e 66 f2 ff d0          notrack bnd callw \*%ax
+[      ]*[a-f0-9]+:    3e f2 ff e0             notrack bnd jmp \*%eax
+[      ]*[a-f0-9]+:    3e 66 f2 ff e0          notrack bnd jmpw \*%ax
+[      ]*[a-f0-9]+:    3e f2 ff 10             notrack bnd call \*\(%eax\)
+[      ]*[a-f0-9]+:    3e 66 f2 ff 10          notrack bnd callw \*\(%eax\)
+[      ]*[a-f0-9]+:    3e f2 ff 20             notrack bnd jmp \*\(%eax\)
+[      ]*[a-f0-9]+:    3e 66 f2 ff 20          notrack bnd jmpw \*\(%eax\)
+[      ]*[a-f0-9]+:    3e f2 ff d0             notrack bnd call \*%eax
+[      ]*[a-f0-9]+:    3e 66 f2 ff d0          notrack bnd callw \*%ax
+[      ]*[a-f0-9]+:    3e f2 ff 10             notrack bnd call \*\(%eax\)
+[      ]*[a-f0-9]+:    3e 66 f2 ff 10          notrack bnd callw \*\(%eax\)
 [      ]*[a-f0-9]+:    f2 3e ff d0             bnd notrack call \*%eax
-[      ]*[a-f0-9]+:    66 f2 3e ff d0          bnd notrack callw \*%ax
-[      ]*[a-f0-9]+:    f2 3e ff e0             bnd notrack jmp \*%eax
-[      ]*[a-f0-9]+:    66 f2 3e ff e0          bnd notrack jmpw \*%ax
-[      ]*[a-f0-9]+:    f2 3e ff 10             bnd notrack call \*\(%eax\)
-[      ]*[a-f0-9]+:    66 f2 3e ff 10          bnd notrack callw \*\(%eax\)
-[      ]*[a-f0-9]+:    f2 3e ff 20             bnd notrack jmp \*\(%eax\)
-[      ]*[a-f0-9]+:    66 f2 3e ff 20          bnd notrack jmpw \*\(%eax\)
-[      ]*[a-f0-9]+:    3e f2 ff d0             ds bnd call \*%eax
-[      ]*[a-f0-9]+:    3e 66 ff d0             ds callw \*%ax
+[      ]*[a-f0-9]+:    66 3e ff d0             notrack callw \*%ax
 #pass
 
        notrack jmp *(%eax)
        notrack jmpw *(%eax)
 
+       notrack bnd call *%eax
+       notrack bnd call *%ax
+       notrack bnd jmp *%eax
+       notrack bnd jmp *%ax
+
+       notrack bnd call *(%eax)
+       notrack bnd callw *(%eax)
+       notrack bnd jmp *(%eax)
+       notrack bnd jmpw *(%eax)
+
        bnd notrack call *%eax
        bnd notrack call *%ax
-       bnd notrack jmp *%eax
-       bnd notrack jmp *%ax
-
        bnd notrack call *(%eax)
        bnd notrack callw *(%eax)
-       bnd notrack jmp *(%eax)
-       bnd notrack jmpw *(%eax)
 
        .intel_syntax noprefix
        notrack call eax
        notrack jmp DWORD PTR [eax]
        notrack jmp WORD PTR [eax]
 
+       notrack bnd call eax
+       notrack bnd call ax
+       notrack bnd jmp eax
+       notrack bnd jmp ax
+
+       notrack bnd call DWORD PTR [eax]
+       notrack bnd call WORD PTR [eax]
+       notrack bnd jmp DWORD PTR [eax]
+       notrack bnd jmp WORD PTR [eax]
+
        bnd notrack call eax
        bnd notrack call ax
-       bnd notrack jmp eax
-       bnd notrack jmp ax
-
        bnd notrack call DWORD PTR [eax]
        bnd notrack call WORD PTR [eax]
-       bnd notrack jmp DWORD PTR [eax]
-       bnd notrack jmp WORD PTR [eax]
 
-       # ds bnd call *%eax
-       .byte 0x3e
+       # bnd notrack call *%eax
        .byte 0xf2
+       .byte 0x3e
        .byte 0xff
        .byte 0xd0
 
-       # ds callw *%ax
-       .byte 0x3e
+       # notrack callw *%ax
        .byte 0x66
+       .byte 0x3e
        .byte 0xff
        .byte 0xd0
 
 .*:6: Error: expecting indirect branch instruction after `notrack'
 .*:6: Warning: skipping prefixes on this instruction
 .*:7: Error: expecting indirect branch instruction after `notrack'
-.*:7: Warning: skipping prefixes on this instruction
 .*:9: Error: same type of prefix used twice
-.*:10: Error: expecting no other prefixes after `notrack'
-.*:11: Error: expecting no other prefixes after `notrack'
-.*:12: Error: expecting no other prefixes after `notrack'
-.*:15: Error: same type of prefix used twice
-.*:16: Error: expecting no other prefixes after `notrack'
-.*:17: Error: expecting no other prefixes after `notrack'
-.*:18: Error: expecting no other prefixes after `notrack'
+.*:10: Error: same type of prefix used twice
+.*:13: Error: same type of prefix used twice
+.*:14: Error: same type of prefix used twice
 GAS LISTING .*
 
 
 [      ]*6[    ]+[0-9A-F]*
 [      ]*7[    ]+\?\?\?\? [0-9A-F]*            notrack jmp foo
 \*\*\*\*  Error: expecting indirect branch instruction after `notrack'
-\*\*\*\*  Warning: skipping prefixes on this instruction
 [      ]*7[    ]+[0-9A-F]*
 [      ]*8[    ]+
 [      ]*9[    ]+fs notrack call \*%eax
 [      ]*10[   ]+notrack fs call \*%eax
-[      ]*11[   ]+notrack bnd call \*%eax
-[      ]*12[   ]+notrack data16 call \*%eax
-[      ]*13[   ]+
-[      ]*14[   ]+\.intel_syntax noprefix
-[      ]*15[   ]+fs notrack call eax
-[      ]*16[   ]+notrack fs call eax
-[      ]*17[   ]+notrack bnd call eax
-[      ]*18[   ]+[\? 0-9A-F]*[         ]+notrack data16 call eax
+[      ]*11[   ]+
+[      ]*12[   ]+\.intel_syntax noprefix
+[      ]*13[   ]+fs notrack call eax
+[      ]*14[   ]+notrack fs call eax
 #pass
 
 
        fs notrack call *%eax
        notrack fs call *%eax
-       notrack bnd call *%eax
-       notrack data16 call *%eax
 
        .intel_syntax noprefix
        fs notrack call eax
        notrack fs call eax
-       notrack bnd call eax
-       notrack data16 call eax
+
+       .p2align        4,0
 
 [      ]*[a-f0-9]+:    3e 41 ff 10             notrack call QWORD PTR \[r8\]
 [      ]*[a-f0-9]+:    3e ff 20                notrack jmp QWORD PTR \[rax\]
 [      ]*[a-f0-9]+:    3e 41 ff 20             notrack jmp QWORD PTR \[r8\]
-[      ]*[a-f0-9]+:    67 3e ff 10             notrack call QWORD PTR \[eax\]
-[      ]*[a-f0-9]+:    67 3e 41 ff 10          notrack call QWORD PTR \[r8d\]
-[      ]*[a-f0-9]+:    67 3e ff 20             notrack jmp QWORD PTR \[eax\]
-[      ]*[a-f0-9]+:    67 3e 41 ff 20          notrack jmp QWORD PTR \[r8d\]
-[      ]*[a-f0-9]+:    f2 3e ff d0             bnd notrack call rax
-[      ]*[a-f0-9]+:    f2 3e 41 ff d0          bnd notrack call r8
-[      ]*[a-f0-9]+:    f2 3e ff e0             bnd notrack jmp rax
-[      ]*[a-f0-9]+:    f2 3e 41 ff e0          bnd notrack jmp r8
-[      ]*[a-f0-9]+:    f2 3e ff 10             bnd notrack call QWORD PTR \[rax\]
-[      ]*[a-f0-9]+:    f2 3e 41 ff 10          bnd notrack call QWORD PTR \[r8\]
-[      ]*[a-f0-9]+:    f2 3e ff 20             bnd notrack jmp QWORD PTR \[rax\]
-[      ]*[a-f0-9]+:    f2 3e 41 ff 20          bnd notrack jmp QWORD PTR \[r8\]
-[      ]*[a-f0-9]+:    67 f2 3e ff 10          bnd notrack call QWORD PTR \[eax\]
-[      ]*[a-f0-9]+:    67 f2 3e 41 ff 10       bnd notrack call QWORD PTR \[r8d\]
-[      ]*[a-f0-9]+:    67 f2 3e ff 20          bnd notrack jmp QWORD PTR \[eax\]
-[      ]*[a-f0-9]+:    67 f2 3e 41 ff 20       bnd notrack jmp QWORD PTR \[r8d\]
+[      ]*[a-f0-9]+:    3e 67 ff 10             notrack call QWORD PTR \[eax\]
+[      ]*[a-f0-9]+:    3e 67 41 ff 10          notrack call QWORD PTR \[r8d\]
+[      ]*[a-f0-9]+:    3e 67 ff 20             notrack jmp QWORD PTR \[eax\]
+[      ]*[a-f0-9]+:    3e 67 41 ff 20          notrack jmp QWORD PTR \[r8d\]
+[      ]*[a-f0-9]+:    3e f2 ff d0             notrack bnd call rax
+[      ]*[a-f0-9]+:    3e f2 41 ff d0          notrack bnd call r8
+[      ]*[a-f0-9]+:    3e f2 ff e0             notrack bnd jmp rax
+[      ]*[a-f0-9]+:    3e f2 41 ff e0          notrack bnd jmp r8
+[      ]*[a-f0-9]+:    3e f2 ff 10             notrack bnd call QWORD PTR \[rax\]
+[      ]*[a-f0-9]+:    3e f2 41 ff 10          notrack bnd call QWORD PTR \[r8\]
+[      ]*[a-f0-9]+:    3e f2 ff 20             notrack bnd jmp QWORD PTR \[rax\]
+[      ]*[a-f0-9]+:    3e f2 41 ff 20          notrack bnd jmp QWORD PTR \[r8\]
+[      ]*[a-f0-9]+:    3e 67 f2 ff 10          notrack bnd call QWORD PTR \[eax\]
+[      ]*[a-f0-9]+:    3e 67 f2 41 ff 10       notrack bnd call QWORD PTR \[r8d\]
+[      ]*[a-f0-9]+:    3e 67 f2 ff 20          notrack bnd jmp QWORD PTR \[eax\]
+[      ]*[a-f0-9]+:    3e 67 f2 41 ff 20       notrack bnd jmp QWORD PTR \[r8d\]
+[      ]*[a-f0-9]+:    3e f2 ff d0             notrack bnd call rax
+[      ]*[a-f0-9]+:    3e f2 41 ff d0          notrack bnd call r8
+[      ]*[a-f0-9]+:    3e f2 ff 10             notrack bnd call QWORD PTR \[rax\]
+[      ]*[a-f0-9]+:    3e f2 41 ff 10          notrack bnd call QWORD PTR \[r8\]
+[      ]*[a-f0-9]+:    3e 67 f2 ff 10          notrack bnd call QWORD PTR \[eax\]
+[      ]*[a-f0-9]+:    3e 67 f2 41 ff 10       notrack bnd call QWORD PTR \[r8d\]
 [      ]*[a-f0-9]+:    3e ff d0                notrack call rax
 [      ]*[a-f0-9]+:    3e 41 ff d0             notrack call r8
 [      ]*[a-f0-9]+:    3e ff e0                notrack jmp rax
 [      ]*[a-f0-9]+:    3e 41 ff 10             notrack call QWORD PTR \[r8\]
 [      ]*[a-f0-9]+:    3e ff 20                notrack jmp QWORD PTR \[rax\]
 [      ]*[a-f0-9]+:    3e 41 ff 20             notrack jmp QWORD PTR \[r8\]
-[      ]*[a-f0-9]+:    67 3e ff 10             notrack call QWORD PTR \[eax\]
-[      ]*[a-f0-9]+:    67 3e 41 ff 10          notrack call QWORD PTR \[r8d\]
-[      ]*[a-f0-9]+:    67 3e ff 20             notrack jmp QWORD PTR \[eax\]
-[      ]*[a-f0-9]+:    67 3e 41 ff 20          notrack jmp QWORD PTR \[r8d\]
+[      ]*[a-f0-9]+:    3e 67 ff 10             notrack call QWORD PTR \[eax\]
+[      ]*[a-f0-9]+:    3e 67 41 ff 10          notrack call QWORD PTR \[r8d\]
+[      ]*[a-f0-9]+:    3e 67 ff 20             notrack jmp QWORD PTR \[eax\]
+[      ]*[a-f0-9]+:    3e 67 41 ff 20          notrack jmp QWORD PTR \[r8d\]
+[      ]*[a-f0-9]+:    3e f2 ff d0             notrack bnd call rax
+[      ]*[a-f0-9]+:    3e f2 41 ff d0          notrack bnd call r8
+[      ]*[a-f0-9]+:    3e f2 ff e0             notrack bnd jmp rax
+[      ]*[a-f0-9]+:    3e f2 41 ff e0          notrack bnd jmp r8
+[      ]*[a-f0-9]+:    3e f2 ff 10             notrack bnd call QWORD PTR \[rax\]
+[      ]*[a-f0-9]+:    3e f2 41 ff 10          notrack bnd call QWORD PTR \[r8\]
+[      ]*[a-f0-9]+:    3e f2 ff 20             notrack bnd jmp QWORD PTR \[rax\]
+[      ]*[a-f0-9]+:    3e f2 41 ff 20          notrack bnd jmp QWORD PTR \[r8\]
+[      ]*[a-f0-9]+:    3e 67 f2 ff 10          notrack bnd call QWORD PTR \[eax\]
+[      ]*[a-f0-9]+:    3e 67 f2 41 ff 10       notrack bnd call QWORD PTR \[r8d\]
+[      ]*[a-f0-9]+:    3e 67 f2 ff 20          notrack bnd jmp QWORD PTR \[eax\]
+[      ]*[a-f0-9]+:    3e 67 f2 41 ff 20       notrack bnd jmp QWORD PTR \[r8d\]
+[      ]*[a-f0-9]+:    3e f2 ff d0             notrack bnd call rax
+[      ]*[a-f0-9]+:    3e f2 41 ff d0          notrack bnd call r8
+[      ]*[a-f0-9]+:    3e f2 ff 10             notrack bnd call QWORD PTR \[rax\]
+[      ]*[a-f0-9]+:    3e f2 41 ff 10          notrack bnd call QWORD PTR \[r8\]
+[      ]*[a-f0-9]+:    3e 67 f2 ff 10          notrack bnd call QWORD PTR \[eax\]
+[      ]*[a-f0-9]+:    3e 67 f2 41 ff 10       notrack bnd call QWORD PTR \[r8d\]
 [      ]*[a-f0-9]+:    f2 3e ff d0             bnd notrack call rax
-[      ]*[a-f0-9]+:    f2 3e 41 ff d0          bnd notrack call r8
-[      ]*[a-f0-9]+:    f2 3e ff e0             bnd notrack jmp rax
-[      ]*[a-f0-9]+:    f2 3e 41 ff e0          bnd notrack jmp r8
-[      ]*[a-f0-9]+:    f2 3e ff 10             bnd notrack call QWORD PTR \[rax\]
-[      ]*[a-f0-9]+:    f2 3e 41 ff 10          bnd notrack call QWORD PTR \[r8\]
-[      ]*[a-f0-9]+:    f2 3e ff 20             bnd notrack jmp QWORD PTR \[rax\]
-[      ]*[a-f0-9]+:    f2 3e 41 ff 20          bnd notrack jmp QWORD PTR \[r8\]
-[      ]*[a-f0-9]+:    67 f2 3e ff 10          bnd notrack call QWORD PTR \[eax\]
-[      ]*[a-f0-9]+:    67 f2 3e 41 ff 10       bnd notrack call QWORD PTR \[r8d\]
-[      ]*[a-f0-9]+:    67 f2 3e ff 20          bnd notrack jmp QWORD PTR \[eax\]
-[      ]*[a-f0-9]+:    67 f2 3e 41 ff 20       bnd notrack jmp QWORD PTR \[r8d\]
-[      ]*[a-f0-9]+:    3e f2 ff d0             ds bnd call rax
 [      ]*[a-f0-9]+:    3e 66 ff d0             ds call ax
 [      ]*[a-f0-9]+:    66 3e ff d0             ds call ax
 #pass
 
 [      ]*[a-f0-9]+:    3e 41 ff 10             notrack callq \*\(%r8\)
 [      ]*[a-f0-9]+:    3e ff 20                notrack jmpq \*\(%rax\)
 [      ]*[a-f0-9]+:    3e 41 ff 20             notrack jmpq \*\(%r8\)
-[      ]*[a-f0-9]+:    67 3e ff 10             notrack callq \*\(%eax\)
-[      ]*[a-f0-9]+:    67 3e 41 ff 10          notrack callq \*\(%r8d\)
-[      ]*[a-f0-9]+:    67 3e ff 20             notrack jmpq \*\(%eax\)
-[      ]*[a-f0-9]+:    67 3e 41 ff 20          notrack jmpq \*\(%r8d\)
-[      ]*[a-f0-9]+:    f2 3e ff d0             bnd notrack callq \*%rax
-[      ]*[a-f0-9]+:    f2 3e 41 ff d0          bnd notrack callq \*%r8
-[      ]*[a-f0-9]+:    f2 3e ff e0             bnd notrack jmpq \*%rax
-[      ]*[a-f0-9]+:    f2 3e 41 ff e0          bnd notrack jmpq \*%r8
-[      ]*[a-f0-9]+:    f2 3e ff 10             bnd notrack callq \*\(%rax\)
-[      ]*[a-f0-9]+:    f2 3e 41 ff 10          bnd notrack callq \*\(%r8\)
-[      ]*[a-f0-9]+:    f2 3e ff 20             bnd notrack jmpq \*\(%rax\)
-[      ]*[a-f0-9]+:    f2 3e 41 ff 20          bnd notrack jmpq \*\(%r8\)
-[      ]*[a-f0-9]+:    67 f2 3e ff 10          bnd notrack callq \*\(%eax\)
-[      ]*[a-f0-9]+:    67 f2 3e 41 ff 10       bnd notrack callq \*\(%r8d\)
-[      ]*[a-f0-9]+:    67 f2 3e ff 20          bnd notrack jmpq \*\(%eax\)
-[      ]*[a-f0-9]+:    67 f2 3e 41 ff 20       bnd notrack jmpq \*\(%r8d\)
+[      ]*[a-f0-9]+:    3e 67 ff 10             notrack callq \*\(%eax\)
+[      ]*[a-f0-9]+:    3e 67 41 ff 10          notrack callq \*\(%r8d\)
+[      ]*[a-f0-9]+:    3e 67 ff 20             notrack jmpq \*\(%eax\)
+[      ]*[a-f0-9]+:    3e 67 41 ff 20          notrack jmpq \*\(%r8d\)
+[      ]*[a-f0-9]+:    3e f2 ff d0             notrack bnd callq \*%rax
+[      ]*[a-f0-9]+:    3e f2 41 ff d0          notrack bnd callq \*%r8
+[      ]*[a-f0-9]+:    3e f2 ff e0             notrack bnd jmpq \*%rax
+[      ]*[a-f0-9]+:    3e f2 41 ff e0          notrack bnd jmpq \*%r8
+[      ]*[a-f0-9]+:    3e f2 ff 10             notrack bnd callq \*\(%rax\)
+[      ]*[a-f0-9]+:    3e f2 41 ff 10          notrack bnd callq \*\(%r8\)
+[      ]*[a-f0-9]+:    3e f2 ff 20             notrack bnd jmpq \*\(%rax\)
+[      ]*[a-f0-9]+:    3e f2 41 ff 20          notrack bnd jmpq \*\(%r8\)
+[      ]*[a-f0-9]+:    3e 67 f2 ff 10          notrack bnd callq \*\(%eax\)
+[      ]*[a-f0-9]+:    3e 67 f2 41 ff 10       notrack bnd callq \*\(%r8d\)
+[      ]*[a-f0-9]+:    3e 67 f2 ff 20          notrack bnd jmpq \*\(%eax\)
+[      ]*[a-f0-9]+:    3e 67 f2 41 ff 20       notrack bnd jmpq \*\(%r8d\)
+[      ]*[a-f0-9]+:    3e f2 ff d0             notrack bnd callq \*%rax
+[      ]*[a-f0-9]+:    3e f2 41 ff d0          notrack bnd callq \*%r8
+[      ]*[a-f0-9]+:    3e f2 ff 10             notrack bnd callq \*\(%rax\)
+[      ]*[a-f0-9]+:    3e f2 41 ff 10          notrack bnd callq \*\(%r8\)
+[      ]*[a-f0-9]+:    3e 67 f2 ff 10          notrack bnd callq \*\(%eax\)
+[      ]*[a-f0-9]+:    3e 67 f2 41 ff 10       notrack bnd callq \*\(%r8d\)
 [      ]*[a-f0-9]+:    3e ff d0                notrack callq \*%rax
 [      ]*[a-f0-9]+:    3e 41 ff d0             notrack callq \*%r8
 [      ]*[a-f0-9]+:    3e ff e0                notrack jmpq \*%rax
 [      ]*[a-f0-9]+:    3e 41 ff 10             notrack callq \*\(%r8\)
 [      ]*[a-f0-9]+:    3e ff 20                notrack jmpq \*\(%rax\)
 [      ]*[a-f0-9]+:    3e 41 ff 20             notrack jmpq \*\(%r8\)
-[      ]*[a-f0-9]+:    67 3e ff 10             notrack callq \*\(%eax\)
-[      ]*[a-f0-9]+:    67 3e 41 ff 10          notrack callq \*\(%r8d\)
-[      ]*[a-f0-9]+:    67 3e ff 20             notrack jmpq \*\(%eax\)
-[      ]*[a-f0-9]+:    67 3e 41 ff 20          notrack jmpq \*\(%r8d\)
+[      ]*[a-f0-9]+:    3e 67 ff 10             notrack callq \*\(%eax\)
+[      ]*[a-f0-9]+:    3e 67 41 ff 10          notrack callq \*\(%r8d\)
+[      ]*[a-f0-9]+:    3e 67 ff 20             notrack jmpq \*\(%eax\)
+[      ]*[a-f0-9]+:    3e 67 41 ff 20          notrack jmpq \*\(%r8d\)
+[      ]*[a-f0-9]+:    3e f2 ff d0             notrack bnd callq \*%rax
+[      ]*[a-f0-9]+:    3e f2 41 ff d0          notrack bnd callq \*%r8
+[      ]*[a-f0-9]+:    3e f2 ff e0             notrack bnd jmpq \*%rax
+[      ]*[a-f0-9]+:    3e f2 41 ff e0          notrack bnd jmpq \*%r8
+[      ]*[a-f0-9]+:    3e f2 ff 10             notrack bnd callq \*\(%rax\)
+[      ]*[a-f0-9]+:    3e f2 41 ff 10          notrack bnd callq \*\(%r8\)
+[      ]*[a-f0-9]+:    3e f2 ff 20             notrack bnd jmpq \*\(%rax\)
+[      ]*[a-f0-9]+:    3e f2 41 ff 20          notrack bnd jmpq \*\(%r8\)
+[      ]*[a-f0-9]+:    3e 67 f2 ff 10          notrack bnd callq \*\(%eax\)
+[      ]*[a-f0-9]+:    3e 67 f2 41 ff 10       notrack bnd callq \*\(%r8d\)
+[      ]*[a-f0-9]+:    3e 67 f2 ff 20          notrack bnd jmpq \*\(%eax\)
+[      ]*[a-f0-9]+:    3e 67 f2 41 ff 20       notrack bnd jmpq \*\(%r8d\)
+[      ]*[a-f0-9]+:    3e f2 ff d0             notrack bnd callq \*%rax
+[      ]*[a-f0-9]+:    3e f2 41 ff d0          notrack bnd callq \*%r8
+[      ]*[a-f0-9]+:    3e f2 ff 10             notrack bnd callq \*\(%rax\)
+[      ]*[a-f0-9]+:    3e f2 41 ff 10          notrack bnd callq \*\(%r8\)
+[      ]*[a-f0-9]+:    3e 67 f2 ff 10          notrack bnd callq \*\(%eax\)
+[      ]*[a-f0-9]+:    3e 67 f2 41 ff 10       notrack bnd callq \*\(%r8d\)
 [      ]*[a-f0-9]+:    f2 3e ff d0             bnd notrack callq \*%rax
-[      ]*[a-f0-9]+:    f2 3e 41 ff d0          bnd notrack callq \*%r8
-[      ]*[a-f0-9]+:    f2 3e ff e0             bnd notrack jmpq \*%rax
-[      ]*[a-f0-9]+:    f2 3e 41 ff e0          bnd notrack jmpq \*%r8
-[      ]*[a-f0-9]+:    f2 3e ff 10             bnd notrack callq \*\(%rax\)
-[      ]*[a-f0-9]+:    f2 3e 41 ff 10          bnd notrack callq \*\(%r8\)
-[      ]*[a-f0-9]+:    f2 3e ff 20             bnd notrack jmpq \*\(%rax\)
-[      ]*[a-f0-9]+:    f2 3e 41 ff 20          bnd notrack jmpq \*\(%r8\)
-[      ]*[a-f0-9]+:    67 f2 3e ff 10          bnd notrack callq \*\(%eax\)
-[      ]*[a-f0-9]+:    67 f2 3e 41 ff 10       bnd notrack callq \*\(%r8d\)
-[      ]*[a-f0-9]+:    67 f2 3e ff 20          bnd notrack jmpq \*\(%eax\)
-[      ]*[a-f0-9]+:    67 f2 3e 41 ff 20       bnd notrack jmpq \*\(%r8d\)
-[      ]*[a-f0-9]+:    3e f2 ff d0             ds bnd callq \*%rax
 [      ]*[a-f0-9]+:    3e 66 ff d0             ds callw \*%ax
 [      ]*[a-f0-9]+:    66 3e ff d0             ds callw \*%ax
 #pass
 
        notrack jmp *(%eax)
        notrack jmp *(%r8d)
 
+       notrack bnd call *%rax
+       notrack bnd call *%r8
+       notrack bnd jmp *%rax
+       notrack bnd jmp *%r8
+
+       notrack bnd call *(%rax)
+       notrack bnd call *(%r8)
+       notrack bnd jmp *(%rax)
+       notrack bnd jmp *(%r8)
+
+       notrack bnd call *(%eax)
+       notrack bnd call *(%r8d)
+       notrack bnd jmp *(%eax)
+       notrack bnd jmp *(%r8d)
+
        bnd notrack call *%rax
        bnd notrack call *%r8
-       bnd notrack jmp *%rax
-       bnd notrack jmp *%r8
-
        bnd notrack call *(%rax)
        bnd notrack call *(%r8)
-       bnd notrack jmp *(%rax)
-       bnd notrack jmp *(%r8)
-
        bnd notrack call *(%eax)
        bnd notrack call *(%r8d)
-       bnd notrack jmp *(%eax)
-       bnd notrack jmp *(%r8d)
 
        .intel_syntax noprefix
        notrack call rax
        notrack jmp QWORD PTR [eax]
        notrack jmp QWORD PTR [r8d]
 
+       notrack bnd call rax
+       notrack bnd call r8
+       notrack bnd jmp rax
+       notrack bnd jmp r8
+
+       notrack bnd call QWORD PTR [rax]
+       notrack bnd call QWORD PTR [r8]
+       notrack bnd jmp QWORD PTR [rax]
+       notrack bnd jmp QWORD PTR [r8]
+
+       notrack bnd call QWORD PTR [eax]
+       notrack bnd call QWORD PTR [r8d]
+       notrack bnd jmp QWORD PTR [eax]
+       notrack bnd jmp QWORD PTR [r8d]
+
        bnd notrack call rax
        bnd notrack call r8
-       bnd notrack jmp rax
-       bnd notrack jmp r8
-
        bnd notrack call QWORD PTR [rax]
        bnd notrack call QWORD PTR [r8]
-       bnd notrack jmp QWORD PTR [rax]
-       bnd notrack jmp QWORD PTR [r8]
-
        bnd notrack call QWORD PTR [eax]
        bnd notrack call QWORD PTR [r8d]
-       bnd notrack jmp QWORD PTR [eax]
-       bnd notrack jmp QWORD PTR [r8d]
 
-       # ds bnd callq *%rax
-       .byte 0x3e
+       # bnd notrack callq *%rax
        .byte 0xf2
+       .byte 0x3e
        .byte 0xff
        .byte 0xd0
 
 
 .*:6: Error: expecting indirect branch instruction after `notrack'
 .*:6: Warning: skipping prefixes on this instruction
 .*:7: Error: expecting indirect branch instruction after `notrack'
-.*:7: Warning: skipping prefixes on this instruction
 .*:9: Error: same type of prefix used twice
-.*:10: Error: expecting no other prefixes after `notrack'
-.*:11: Error: expecting no other prefixes after `notrack'
-.*:12: Error: expecting no other prefixes after `notrack'
-.*:15: Error: same type of prefix used twice
-.*:16: Error: expecting no other prefixes after `notrack'
-.*:17: Error: expecting no other prefixes after `notrack'
-.*:18: Error: expecting no other prefixes after `notrack'
+.*:10: Error: same type of prefix used twice
+.*:13: Error: same type of prefix used twice
+.*:14: Error: same type of prefix used twice
 GAS LISTING .*
 
 
 [      ]*6[    ]+[0-9A-F]*
 [      ]*7[    ]+\?\?\?\? [0-9A-F]*            notrack jmp foo
 \*\*\*\*  Error: expecting indirect branch instruction after `notrack'
-\*\*\*\*  Warning: skipping prefixes on this instruction
 [      ]*7[    ]+[0-9A-F]*
 [      ]*8[    ]+
 [      ]*9[    ]+fs notrack call \*%rax
 [      ]*10[   ]+notrack fs call \*%rax
-[      ]*11[   ]+notrack bnd call \*%rax
-[      ]*12[   ]+notrack data16 call \*%rax
-[      ]*13[   ]+
-[      ]*14[   ]+\.intel_syntax noprefix
-[      ]*15[   ]+fs notrack call rax
-[      ]*16[   ]+notrack fs call rax
-[      ]*17[   ]+notrack bnd call rax
-[      ]*18[   ]+[\? 0-9A-F]*[         ]+notrack data16 call rax
+[      ]*11[   ]+
+[      ]*12[   ]+\.intel_syntax noprefix
+[      ]*13[   ]+fs notrack call rax
+[      ]*14[   ]+notrack fs call rax
 #pass
 
 
        fs notrack call *%rax
        notrack fs call *%rax
-       notrack bnd call *%rax
-       notrack data16 call *%rax
 
        .intel_syntax noprefix
        fs notrack call rax
        notrack fs call rax
-       notrack bnd call rax
-       notrack data16 call rax
+
+       .p2align        4,0
 
+2017-09-09  H.J. Lu  <hongjiu.lu@intel.com>
+
+       * i386-dis.c (last_active_prefix): Removed.
+       (ckprefix): Don't set last_active_prefix.
+       (NOTRACK_Fixup): Don't check last_active_prefix.
+
 2017-08-31  Nick Clifton  <nickc@redhat.com>
 
        * po/fr.po: Updated French translation.
 
 static int last_addr_prefix;
 static int last_rex_prefix;
 static int last_seg_prefix;
-static int last_active_prefix;
 static int fwait_prefix;
 /* The active segment register prefix.  */
 static int active_seg_prefix;
   last_addr_prefix = -1;
   last_rex_prefix = -1;
   last_seg_prefix = -1;
-  last_active_prefix = -1;
   fwait_prefix = -1;
   active_seg_prefix = 0;
   for (i = 0; i < (int) ARRAY_SIZE (all_prefixes); i++)
          return 1;
        }
       if (*codep != FWAIT_OPCODE)
-       {
-         last_active_prefix = i;
-         all_prefixes[i++] = *codep;
-       }
+       all_prefixes[i++] = *codep;
       rex = newrex;
       codep++;
       length++;
   if (active_seg_prefix == PREFIX_DS
       && (address_mode != mode_64bit || last_data_prefix < 0))
     {
-      /* NOTRACK prefix is only valid on indirect branch instructions
-         and it must be the last prefix before REX prefix and opcode.
+      /* NOTRACK prefix is only valid on indirect branch instructions.
         NB: DATA prefix is unsupported for Intel64.  */
-      if (last_active_prefix >= 0)
-       {
-         int notrack_prefix = last_active_prefix;
-         if (last_rex_prefix == last_active_prefix)
-           notrack_prefix--;
-         if (all_prefixes[notrack_prefix] != NOTRACK_PREFIX_OPCODE)
-           return;
-       }
       active_seg_prefix = 0;
       all_prefixes[last_seg_prefix] = NOTRACK_PREFIX;
     }