Issue 204535
Summary [Analysis] `@llvm.pdep` can be transformed into squaring with `@llvm.clmul`, and vice versa
Labels
Assignees
Reporter eisenwave
    `pdep` with an alternating bit pattern like `0b01010101...` is used to perform bitwise interleaving. See https://stackoverflow.com/a/79962549/5740428

On platforms where there exists `clmul` but no `pdep` (e.g. RISC-V) or x86_64 CPUs with the PCLMUL extensions but no BMI2, it is beneficial to transform `pdep` into `clmul` if such a mask is detected.

That is, `pdep(x, 0b10101010...) -> clmul(x, x)`.

The inverse is also possible and potentially beneficial because on x86_64, CLMUL is done through vector registers, so there is a bit of fluff just to get things set up and extract the result in the case of scalar operations. That is, `clmul(x, x) -> pdep(x, 0b1010101010...)`.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to