+2020-10-05  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR binutils/26705
+       * testsuite/gas/i386/x86-64-suffix.s: Add "mov %rsp,%rbp" before
+       sysretq.
+       * testsuite/gas/i386/x86-64-suffix-intel.d: Updated.
+       * testsuite/gas/i386/x86-64-suffix.d: Likewise.
+
 2020-10-05  Nick Clifton  <nickc@redhat.com>
 
        PR 26253
 
 [      ]*[a-f0-9]+:    cf                      iretd  
 [      ]*[a-f0-9]+:    48 cf                   iretq  
 [      ]*[a-f0-9]+:    0f 07                   sysretd 
+[      ]*[a-f0-9]+:    48 89 e5                mov    rbp,rsp
 [      ]*[a-f0-9]+:    48 0f 07                sysretq 
 [      ]*[a-f0-9]+:    66 cf                   iretw  
 [      ]*[a-f0-9]+:    cf                      iretd  
 [      ]*[a-f0-9]+:    cf                      iretd  
 [      ]*[a-f0-9]+:    48 cf                   iretq  
 [      ]*[a-f0-9]+:    0f 07                   sysretd 
+[      ]*[a-f0-9]+:    48 89 e5                mov    rbp,rsp
 [      ]*[a-f0-9]+:    48 0f 07                sysretq 
 #pass
 
 [      ]*[a-f0-9]+:    cf                      iretl  
 [      ]*[a-f0-9]+:    48 cf                   iretq  
 [      ]*[a-f0-9]+:    0f 07                   sysretl 
+[      ]*[a-f0-9]+:    48 89 e5                movq   %rsp,%rbp
 [      ]*[a-f0-9]+:    48 0f 07                sysretq 
 [      ]*[a-f0-9]+:    66 cf                   iretw  
 [      ]*[a-f0-9]+:    cf                      iretl  
 [      ]*[a-f0-9]+:    cf                      iretl  
 [      ]*[a-f0-9]+:    48 cf                   iretq  
 [      ]*[a-f0-9]+:    0f 07                   sysretl 
+[      ]*[a-f0-9]+:    48 89 e5                movq   %rsp,%rbp
 [      ]*[a-f0-9]+:    48 0f 07                sysretq 
 #pass
 
        iretl
        iretq
        sysretl
+       mov     %rsp,%rbp
        sysretq
 
        .intel_syntax noprefix
        iret
        iretq
        sysretd
+       mov     rbp,rsp
        sysretq
 
+2020-10-05  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR binutils/26705
+       * i386-dis.c (print_insn): Clear modrm if not needed.
+       (putop): Check need_modrm for modrm.mod != 3.  Don't check
+       need_modrm for modrm.mod == 3.
+
 2020-09-28  Przemyslaw Wirkus  <przemyslaw.wirkus@arm.com>
 
        * aarch64-opc.c: Added ETMv4 system registers TRCACATRn, TRCACVRn,
 
       FETCH_DATA (info, codep + 1);
       threebyte = *codep;
       dp = &dis386_twobyte[threebyte];
-      need_modrm = twobyte_has_modrm[*codep];
+      need_modrm = twobyte_has_modrm[threebyte];
       codep++;
     }
   else
       modrm.reg = (*codep >> 3) & 7;
       modrm.rm = *codep & 7;
     }
+  else
+    memset (&modrm, 0, sizeof (modrm));
 
   need_vex = 0;
   memset (&vex, 0, sizeof (vex));
        case 'A':
          if (intel_syntax)
            break;
-         if (modrm.mod != 3 || (sizeflag & SUFFIX_ALWAYS))
+         if ((need_modrm && modrm.mod != 3)
+             || (sizeflag & SUFFIX_ALWAYS))
            *obufp++ = 'b';
          break;
        case 'B':
        case 'P':
          if (l == 0)
            {
-             if (((need_modrm && modrm.mod == 3) || !cond)
+             if ((modrm.mod == 3 || !cond)
                  && !(sizeflag & SUFFIX_ALWAYS))
                break;
          /* Fall through.  */
              if (intel_syntax && !alt)
                break;
              USED_REX (REX_W);
-             if (modrm.mod != 3 || (sizeflag & SUFFIX_ALWAYS))
+             if ((need_modrm && modrm.mod != 3)
+                 || (sizeflag & SUFFIX_ALWAYS))
                {
                  if (rex & REX_W)
                    *obufp++ = 'q';