[llvm] Perform bitreverse using AVX512 GFNI for i32 and i64. (PR #81764)

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 15 02:27:49 PST 2024


================
@@ -31040,17 +31044,63 @@ static SDValue LowerBITREVERSE_XOP(SDValue Op, SelectionDAG &DAG) {
   return DAG.getBitcast(VT, Res);
 }
 
+static auto createBSWAPShuffleMask(EVT VT) {
+  SmallVector<int, 16> ShuffleMask;
+  int ScalarSizeInBytes = VT.getScalarSizeInBits() / 8;
+  for (int I = 0, E = VT.getVectorNumElements(); I != E; ++I)
+    for (int J = ScalarSizeInBytes - 1; J >= 0; --J)
+      ShuffleMask.push_back((I * ScalarSizeInBytes) + J);
+
+  return ShuffleMask;
+}
+
 static SDValue LowerBITREVERSE(SDValue Op, const X86Subtarget &Subtarget,
                                SelectionDAG &DAG) {
   MVT VT = Op.getSimpleValueType();
+  SDValue In = Op.getOperand(0);
+  SDLoc DL(Op);
+
----------------
RKSimon wrote:

For scalar cases, we'd be better off pulling the scalar code out of LowerBITREVERSE_XOP and just putting it at the top of LowerBITREVERSE - all x86 BITREVERSE custom lowering code uses vector instructions.

https://github.com/llvm/llvm-project/pull/81764


More information about the llvm-commits mailing list