[llvm] [NVPTX] Use PRMT instruction to lower i16 bswap (PR #168968)

Alex MacLean via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 21 15:03:24 PST 2025


================
@@ -2570,6 +2574,45 @@ static SDValue lowerTcgen05St(SDValue Op, SelectionDAG &DAG) {
   return Tcgen05StNode;
 }
 
+static SDValue lowerBSWAP(SDValue Op, SelectionDAG &DAG) {
+  SDLoc DL(Op);
+  SDValue Src = Op.getOperand(0);
+  EVT VT = Op.getValueType();
+
+  if (VT == MVT::i16) {
+    SDValue Extended = DAG.getNode(ISD::ZERO_EXTEND, DL, MVT::i32, Src);
----------------
AlexMaclean wrote:

I think you could use an ANY_EXTEND here.

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


More information about the llvm-commits mailing list