Logical AND Packed Single-Precision Floating-Point Values

Encoding

EncodingOperand 1Operand 2Operand 3Operand 4
rmn/aModRM.reg[rw]ModRM.r/m[r]
rvmn/aModRM.reg[rw]VEX.vvvv[r]ModRM.r/m[r]
ervmfullModRM.reg[rw]EVEX.vvvvv[r]ModRM.r/m[r]

Description

The (V)ANDPS instruction ANDs four, eight, or 16 single-precision floating-point values from the two source operands. The result is stored in the destination operand.

All forms except the legacy SSE one will zero the upper (untouched) bits.

Operation

public void ANDPS(SimdU32 dest, SimdU32 src)
{
    dest[0] &= src[0];
    dest[1] &= src[1];
    dest[2] &= src[2];
    dest[3] &= src[3];
    // dest[4..] is unmodified
}

void VANDPS_Vex(SimdU32 dest, SimdU32 src1, SimdU32 src2, int kl)
{
    for (int n = 0; n < kl; n++)
        dest[n] = src1[n] & src2[n];
    dest[kl..] = 0;
}
public void VANDPS_Vex128(SimdU32 dest, SimdU32 src1, SimdU32 src2) =>
    VANDPS_Vex(dest, src1, src2, 4);
public void VANDPS_Vex256(SimdU32 dest, SimdU32 src1, SimdU32 src2) =>
    VANDPS_Vex(dest, src1, src2, 8);

void VANDPS_EvexMemory(SimdU32 dest, SimdU32 src1, SimdU32 src2, KMask k, int kl)
{
    for (int n = 0; n < kl; n++)
    {
        if (k[n])
            dest[n] = src1[n] & (EVEX.b ? src2[0] : src2[n]);
        else if (EVEX.z)
            dest[n] = 0;
        // otherwise unchanged
    }
    dest[kl..] = 0;
}
public void VANDPS_Evex128Memory(SimdU32 dest, SimdU32 src1, SimdU32 src2, KMask k) =>
    VANDPS_EvexMemory(dest, src1, src2, k, 4);
public void VANDPS_Evex256Memory(SimdU32 dest, SimdU32 src1, SimdU32 src2, KMask k) =>
    VANDPS_EvexMemory(dest, src1, src2, k, 8);
public void VANDPS_Evex512Memory(SimdU32 dest, SimdU32 src1, SimdU32 src2, KMask k) =>
    VANDPS_EvexMemory(dest, src1, src2, k, 16);

void VANDPS_EvexRegister(SimdU32 dest, SimdU32 src1, SimdU32 src2, KMask k, int kl)
{
    if (kl == 16 && EVEX.b)
        OverrideRoundingModeForThisInstruction(EVEX.rc);

    for (int n = 0; n < kl; n++)
    {
        if (k[n])
            dest[n] = src1[n] & src2[n];
        else if (EVEX.z)
            dest[n] = 0;
        // otherwise unchanged
    }
    dest[kl..] = 0;
}
public void VANDPS_Evex128Register(SimdU32 dest, SimdU32 src1, SimdU32 src2, KMask k) =>
    VANDPS_EvexRegister(dest, src1, src2, k, 4);
public void VANDPS_Evex256Register(SimdU32 dest, SimdU32 src1, SimdU32 src2, KMask k) =>
    VANDPS_EvexRegister(dest, src1, src2, k, 8);
public void VANDPS_Evex512Register(SimdU32 dest, SimdU32 src1, SimdU32 src2, KMask k) =>
    VANDPS_EvexRegister(dest, src1, src2, k, 16);

Intrinsics

Exceptions

SIMD Floating-Point

None.

Other Exceptions

VEX Encoded Form: See Type 4 Exception Conditions.
EVEX Encoded Form: See Type E4 Exception Conditions.