kmovq

Move Quadword Mask Register

KMOVQ k1, k2/m64

Moves 64-bit mask to/from k-register.

Details

Moves a 64-bit value between AVX-512 opmask registers (k0–k7) or from/to a 64-bit memory location. Requires AVX-512BW support; destination k-register receives the full 64-bit mask. ZF is set based on source value; CF is typically cleared unless an error occurs.

Pseudocode Operation

if (source_is_register) {
  dest_k ← src_k;
} else {
  dest_k ← [src];
}
ZF ← (dest_k == 0);
CF ← 0;

Example

KMOVQ k1, k2/m64

Encoding

Binary Layout
EVEX
+0
0F
+4
90
+5
 
Format EVEX
Opcode VEX.L0.0F.W1 90 /r
Extension AVX-512BW

Operands

  • dest
    AVX-512 opmask register (k0-k7)
  • src
    AVX-512 opmask register (k0-k7) or Memory operand

Reference (Intel® SDM)

Instruction Forms

Opcode Instruction Op/En 64/32-bit Mode CPUID Description
VEX.L0.0F.W0 90 /r KMOVW k1, k2/m16 RM V/V AVX512F OR AVX10.1 Move 16 bits mask from k2/m16 and store the result in k1.
VEX.L0.66.0F.W0 90 /r KMOVB k1, k2/m8 RM V/V AVX512DQ OR AVX10.1 Move 8 bits mask from k2/m8 and store the result in k1.
VEX.L0.0F.W1 90 /r KMOVQ k1, k2/m64 RM V/V AVX512BW OR AVX10.1 Move 64 bits mask from k2/m64 and store the result in k1.
VEX.L0.66.0F.W1 90 /r KMOVD k1, k2/m32 RM V/V AVX512BW OR AVX10.1 Move 32 bits mask from k2/m32 and store the result in k1.
VEX.L0.0F.W0 91 /r KMOVW m16, k1 MR V/V AVX512F OR AVX10.1 Move 16 bits mask from k1 and store the result in m16.
VEX.L0.66.0F.W0 91 /r KMOVB m8, k1 MR V/V AVX512DQ OR AVX10.1 Move 8 bits mask from k1 and store the result in m8.
VEX.L0.0F.W1 91 /r KMOVQ m64, k1 MR V/V AVX512BW OR AVX10.1 Move 64 bits mask from k1 and store the result in m64.
VEX.L0.66.0F.W1 91 /r KMOVD m32, k1 MR V/V AVX512BW OR AVX10.1 Move 32 bits mask from k1 and store the result in m32.
VEX.L0.0F.W0 92 /r KMOVW k1, r32 V/V RR AVX512F OR AVX10.1 Move 16 bits mask from r32 to k1.
VEX.L0.66.0F.W0 92 /r KMOVB k1, r32 V/V RR AVX512DQ OR AVX10.1 Move 8 bits mask from r32 to k1.
VEX.L0.F2.0F.W1 92 /r KMOVQ k1, r64 V/I RR AVX512BW OR AVX10.1 Move 64 bits mask from r64 to k1.
VEX.L0.F2.0F.W0 92 /r KMOVD k1, r32 V/V RR AVX512BW OR AVX10.1 Move 32 bits mask from r32 to k1.
VEX.L0.0F.W0 93 /r KMOVW r32, k1 V/V RR AVX512F OR AVX10.1 Move 16 bits mask from k1 to r32.
VEX.L0.66.0F.W0 93 /r KMOVB r32, k1 V/V RR AVX512DQ OR AVX10.1 Move 8 bits mask from k1 to r32.
VEX.L0.F2.0F.W1 93 /r KMOVQ r64, k1 V/I RR AVX512BW OR AVX10.1 Move 64 bits mask from k1 to r64.
VEX.L0.F2.0F.W0 93 /r KMOVD r32, k1 V/V RR AVX512BW OR AVX10.1 Move 32 bits mask from k1 to r32.

Description

Copies values from the source operand (second operand) to the destination operand (first operand). The source and destination operands can be mask registers, memory location or general purpose. The instruction cannot be used to transfer data between general purpose registers and or memory locations. KMOVW/KMOVB/KMOVQ/KMOVD—Move From and to Mask Registers Vol. 2A 3-517 When moving to a mask register, the result is zero extended to MAX_KL size (i.e., 64 bits currently). When moving to a general-purpose register (GPR), the result is zero-extended to the size of the destination. In 32-bit mode, the default GPR destination’s size is 32 bits. In 64-bit mode, the default GPR destination’s size is 64 bits. Note that VEX.W can only be used to modify the size of the GPR operand in 64b mode.

Operation

KMOVW
IF *destination is a memory location*
DEST[15:0] := SRC[15:0]
IF *destination is a mask register or a GPR *
DEST := ZeroExtension(SRC[15:0])

KMOVB
IF *destination is a memory location*
DEST[7:0] := SRC[7:0]
IF *destination is a mask register or a GPR *
DEST := ZeroExtension(SRC[7:0])

KMOVQ
IF *destination is a memory location or a GPR*
DEST[63:0] := SRC[63:0]
IF *destination is a mask register*
DEST := ZeroExtension(SRC[63:0])

KMOVD
IF *destination is a memory location*
DEST[31:0] := SRC[31:0]
IF *destination is a mask register or a GPR *
DEST := ZeroExtension(SRC[31:0])

Intel C/C++ Compiler Intrinsic Equivalent

KMOVW __mmask16 _mm512_kmov(__mmask16 a);

Flags Affected

None.

Exceptions

SIMD Floating-Point Exceptions

None.

Other Exceptions

Instructions with RR operand encoding, see Table 2-65, “TYPE K20 Exception Definition (VEX-Encoded OpMask Instructions w/o Memory Arg).” Instructions with RM or MR operand encoding, see Table 2-66, “TYPE K21 Exception Definition (VEX-Encoded OpMask Instructions Addressing Memory).” KMOVW/KMOVB/KMOVQ/KMOVD—Move From and to Mask Registers Vol. 2A 3-518