Issue 178785
Summary [X86] Missed Fold: `vgf2p8affineqb(x, m1) ^ vgf2p8affineqb(x, m2)` => `vgf2p8affineqb(x, m1 ^ m2)`
Labels new issue
Assignees
Reporter WalterKruger
    The matrix in `vgf2p8affineqb` can be interpreted as determining which bits of the input are XORed together for each position. Following from that, XORing two affines of the same input can be folded by XORing both their matrices and immediates together into a single `vgf2p8affineqb` instruction.

```asm
src:
        vgf2p8affineqb  xmm1, xmm0, xmm1, 0
        vgf2p8affineqb  xmm0, xmm0, xmm2, 0
        vpxor xmm0, xmm0, xmm1
        ret
```

```asm
tgt:
        vpxor   xmm1, xmm2, xmm1
        vgf2p8affineqb  xmm0, xmm0, xmm1, 0
 ret
```

https://godbolt.org/z/jK8eWPhb7

This can also be applied to `vgf2p8affineqb(x, m) ^ x`, as the standalone `x` can be interpreted as being affined by the neutral matrix.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to