+2019-07-17  Jan Beulich  <jbeulich@suse.com>
+
+       * config/tc-i386.c (check_hle, md_assemble, check_VecOperands,
+       match_template, check_string, build_modrm_byte): Replace
+       operand_type_check(..., anymem) by Operand_Mem ones.
+       (process_operands): Also copy i.flags[] when copying other
+       operand properties.
+
 2019-07-16  Jan Beulich  <jbeulich@suse.com>
 
        * config/tc-i386.c (match_template): Adjust regmem reference.
 
                  i.tm.name);
          return 0;
        }
-      if (i.mem_operands == 0
-         || !operand_type_check (i.types[i.operands - 1], anymem))
+      if (i.mem_operands == 0 || !(i.flags[i.operands - 1] & Operand_Mem))
        {
          as_bad (_("memory destination needed for instruction `%s'"
                    " after `xrelease'"), i.tm.name);
       && (!i.tm.opcode_modifier.islockable
          || i.mem_operands == 0
          || (i.tm.base_opcode != 0x86
-             && !operand_type_check (i.types[i.operands - 1], anymem))))
+             && !(i.flags[i.operands - 1] & Operand_Mem))))
     {
       as_bad (_("expecting lockable instruction after `lock'"));
       return;
     {
       /* Find memory operand.  */
       for (op = 0; op < i.operands; op++)
-       if (operand_type_check (i.types[op], anymem))
+       if (i.flags[op] & Operand_Mem)
          break;
       gas_assert (op < i.operands);
       /* Check size of the memory operand.  */
 
          i.memshift = 0;
          for (op = 0; op < i.operands; op++)
-           if (operand_type_check (i.types[op], anymem))
+           if (i.flags[op] & Operand_Mem)
              {
                if (t->opcode_modifier.evex == EVEXLIG)
                  i.memshift = 2 + (i.suffix == QWORD_MNEM_SUFFIX);
              && i.hle_prefix
              && t->base_opcode == 0xa0
              && i.types[0].bitfield.acc
-             && operand_type_check (i.types[1], anymem))
+             && (i.flags[1] & Operand_Mem))
            continue;
          /* Fall through.  */
 
 static int
 check_string (void)
 {
-  int mem_op = operand_type_check (i.types[0], anymem) ? 0 : 1;
+  unsigned int mem_op = i.flags[0] & Operand_Mem ? 0 : 1;
+
   if (i.tm.operand_types[mem_op].bitfield.esseg)
     {
       if (i.seg[0] != NULL && i.seg[0] != &es)
                  i.op[j - 1] = i.op[j];
                  i.types[j - 1] = i.types[j];
                  i.tm.operand_types[j - 1] = i.tm.operand_types[j];
+                 i.flags[j - 1] = i.flags[j];
                }
            }
        }
              i.op[j] = i.op[j - 1];
              i.types[j] = i.types[j - 1];
              i.tm.operand_types[j] = i.tm.operand_types[j - 1];
+             i.flags[j] = i.flags[j - 1];
            }
          i.op[0].regs
            = (const reg_entry *) hash_find (reg_hash, "xmm0");
          i.op[dupl] = i.op[dest];
          i.types[dupl] = i.types[dest];
          i.tm.operand_types[dupl] = i.tm.operand_types[dest];
+         i.flags[dupl] = i.flags[dest];
        }
       else
        {
          i.op[dupl] = i.op[dest];
          i.types[dupl] = i.types[dest];
          i.tm.operand_types[dupl] = i.tm.operand_types[dest];
+         i.flags[dupl] = i.flags[dest];
        }
 
        if (i.tm.opcode_modifier.immext)
          /* We need to adjust fields in i.tm since they are used by
             build_modrm_byte.  */
          i.tm.operand_types [j - 1] = i.tm.operand_types [j];
+
+         i.flags[j - 1] = i.flags[j];
        }
 
       i.operands--;
          unsigned int op;
 
          for (op = 0; op < i.operands; op++)
-           if (operand_type_check (i.types[op], anymem))
+           if (i.flags[op] & Operand_Mem)
              break;
          gas_assert (op < i.operands);