+2018-07-26  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR gas/23453
+       * config/tc-i386.c (parse_operands): Check for more than 2
+       memory references.
+       * testsuite/gas/i386/inval.s: Add a movsd test with 3 memory
+       references.
+       * testsuite/gas/i386/x86-64-inval.s: Likewise.
+       * testsuite/gas/i386/inval.l: Updated.
+       * testsuite/gas/i386/x86-64-inval.l: Likewise.
+
 2018-07-26  H.J. Lu  <hongjiu.lu@intel.com>
 
        * config/tc-i386.c (check_VecOperations): Initialize
 
          /* Now parse operand adding info to 'i' as we go along.  */
          END_STRING_AND_SAVE (l);
 
+         if (i.mem_operands > 1)
+           {
+             as_bad (_("too many memory references for `%s'"),
+                     mnemonic);
+             return 0;
+           }
+
          if (intel_syntax)
            operand_ok =
              i386_intel_operand (token_start,
 
 .*:97: Error: .*shl.*
 .*:98: Error: .*rol.*
 .*:99: Error: .*rcl.*
+.*:102: Error: .*
 GAS LISTING .*
 
 
 [      ]*[1-9][0-9]*[  ]+shl \[eax\], 1
 [      ]*[1-9][0-9]*[  ]+rol \[ecx\], 2
 [      ]*[1-9][0-9]*[  ]+rcl \[edx\], cl
+[      ]*[1-9][0-9]*[  ]+
+[      ]*[1-9][0-9]*[  ]+\.att_syntax prefix
+[      ]*[1-9][0-9]*[  ]+movsd \(%esi\), %ss:\(%edi\), %ss:\(%eax\)
 
        shl [eax], 1
        rol [ecx], 2
        rcl [edx], cl
+
+       .att_syntax prefix
+       movsd (%esi), %ss:(%edi), %ss:(%eax)
 
 .*:116: Error: .*
 .*:117: Error: .*
 .*:118: Error: .*
+.*:121: Error: .*
 GAS LISTING .*
 
 
 [      ]*116[  ]+jmpd \[rax\]  \# 32-bit data size not allowed
 [      ]*117[  ]+jmpq \[ax\]   \# no 16-bit addressing
 [      ]*[1-9][0-9]*[  ]+mov eax,\[rax\+0x876543210\] \# out of range displacement
+[      ]*[1-9][0-9]*[  ]+
+[      ]*[1-9][0-9]*[  ]+\.att_syntax prefix
+[      ]*[1-9][0-9]*[  ]+movsd \(%rsi\), %ss:\(%rdi\), %ss:\(%rax\)
 
        jmpd [rax]      # 32-bit data size not allowed
        jmpq [ax]       # no 16-bit addressing
        mov eax,[rax+0x876543210] # out of range displacement
+
+       .att_syntax prefix
+       movsd (%rsi), %ss:(%rdi), %ss:(%rax)