[llvm] [SPARC] Use hardware byteswapper when we have V9 (PR #191720)

Sergei Barannikov via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 14 05:45:45 PDT 2026


================
@@ -3001,6 +3004,37 @@ static SDValue LowerF128Load(SDValue Op, SelectionDAG &DAG)
   return DAG.getMergeValues(Ops, dl);
 }
 
+SDValue SparcTargetLowering::LowerBSWAP(SDValue Op, SelectionDAG &DAG) const {
+  // We don't have an in-register bswap, so expand bswap(x) into
+  // load(store-swapped(x)). The reason the swap is done during the store is
+  // that on some implementations (mainly older ones) ASI-tagged memory
+  // operations are not pipelined, and generally stores finish faster than
+  // loads.
+
+  MachineFunction &MF = DAG.getMachineFunction();
+  MachineFrameInfo &MFI = MF.getFrameInfo();
+  auto PtrVT = getPointerTy(DAG.getDataLayout());
+  SDValue Chain = DAG.getEntryNode();
+  bool IsLittleEndian = DAG.getDataLayout().isLittleEndian();
+  SDLoc DL(Op);
+
+  SDValue BSwapOp = Op.getOperand(0);
+  EVT BSwapVT = BSwapOp.getValueType();
+
+  // Create a stack object to serve as temporary storage.
+  int BSwapFI = MFI.CreateStackObject(BSwapVT.getStoreSize(), Align(8), false);
----------------
s-barannikov wrote:

Why hardcoding aligmnent to 8?

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


More information about the llvm-commits mailing list