11

I see in AVX2 instruction set, Intel distinguishes the XOR operations of integer, double and float with different instructions. For Integer there's "VPXORD", and for double "VXORPD", for float "VXORPS"

However, per my understanding, they should all be the same XOR operation on binary data. E.g., XOR of two 256-bit registers, and has nothing to do with the actual data type. Why do we need to use different instructions for different data types?

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
Harper
  • 1,794
  • 14
  • 31
  • 1
    Possible duplicate of [What's the difference between logical SSE intrinsics?](https://stackoverflow.com/questions/2804902/whats-the-difference-between-logical-sse-intrinsics) – Mysticial Mar 05 '19 at 22:34
  • 1
    @Mysticial: maybe not exactly, [`vpxord/q` requires AVX512F](https://www.felixcloutier.com/x86/pxor) for masking on 32/64-bit elements, but EVEX [`vxorps`](https://www.felixcloutier.com/x86/xorps) (for zmm, or x/ymm16..31) requires AVX512DQ so surprisingly KNL doesn't have it, only "integer" vpxord/q! – Peter Cordes Mar 05 '19 at 22:55
  • Note that unless you need to pad code and want to avoid nops use `vpxor` instead of `vpxor{size}` as you save 2 bytes in the encoding. If you use the intrinsic wrapper [GCC will automatically use the short encoding](https://godbolt.org/z/MPbdKT15W) – Noah Apr 16 '21 at 15:36

0 Answers0