3 ms·
PEXT / PDEP are not instructions that would compile automatically in anything I'm aware of. Its a new fundamental bitwise operator. Some other programmers have
by dragontamer 8y ago
PEXT / PDEP are not instructions that would compile automatically in anything I'm aware of.
Its a new fundamental bitwise operator. Some other programmers have called it a "bitwise gather (pext) or bitwise scatter (pdep)" (EDIT: Had it backwards the first time). Its a very powerful way to think about bits that Intel just invented in those instructions.
If you have any data-structure that is bitwise, I can almost guarantee you that PEXT or PDEP will be useful in some operation. These instructions have been used to calculate bishop / rook moves in less than five operations.
https://www.chessprogramming.org/BMI2#PEXTBitboards https://www.chessprogramming.org/BMI2#PEXTBitboards
And yes, remember that bishops and rooks can be blocked by other pieces. So given all the pieces on a chessboard, and the location of the bishop in question, calculate all possible locations the bishop can move (after accounting for "being blocked").
- 0xffff2 8y agoDon't omptimizers already do quite a lot of analysis to output what you mean rather than what you say? I can think of quite a lot of bitwise shift/and and shift/or patterns that should be automatically convertible to single-instruction pext/pdep's