[llvm] [SelectionDAG] Faster generic expansion of llvm.pext and llvm.pdep (PR #227292)
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 29 05:49:29 PDT 2026
================
@@ -5736,6 +5736,17 @@ class LLVM_ABI TargetLowering : public TargetLoweringBase {
/// \returns The expansion if successful, SDValue() otherwise
SDValue expandCLMUL(SDNode *N, SelectionDAG &DAG) const;
+ /// How expandPEXT and expandPDEP compute the result: Hacker's Delight 7-4
+ /// and 7-5 with carry-less multiplies, one shift-and-XOR network over the
+ /// whole word, or such networks within each byte followed by a variable
+ /// shift per byte.
+ enum class PEXTExpansion { CarryLessMultiply, WholeWord, Bytewise };
+
+ /// Return how to expand PEXT and PDEP of type \p VT. By default, carry-less
+ /// multiplies where CLMUL is legal (or can be lowered, for vectors), bytewise
+ /// for scalars of 16 to 64 bits, and the whole-word network otherwise.
+ virtual PEXTExpansion preferredPEXTExpansion(SelectionDAG &DAG, EVT VT) const;
----------------
RKSimon wrote:
Please don't add TLI callbacks - use isOperationLegal style checks if you can, or have targets use custom lowering that calls specific TargetLowering::expandPDEP* variants.
https://github.com/llvm/llvm-project/pull/227292
More information about the llvm-commits
mailing list