[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


================
@@ -3218,13 +3255,109 @@ SDValue SparcTargetLowering::PerformBITCASTCombine(SDNode *N,
   return SDValue();
 }
 
+SDValue SparcTargetLowering::PerformBSWAPCombine(SDNode *N,
+                                                 DAGCombinerInfo &DCI) const {
+  SDLoc DL(N);
+  SelectionDAG &DAG = DCI.DAG;
+  SDValue Op0 = N->getOperand(0);
+  EVT Op0VT = N->getValueType(0);
+  bool IsLittleEndian = DAG.getDataLayout().isLittleEndian();
+
+  // Turn BSWAP (LOAD) -> ld*a #ASI_P(_L) on V9.
+  if (Subtarget->isV9() && ISD::isNormalLoad(Op0.getNode()) &&
+      Op0.getNode()->hasOneUse() &&
+      (Op0VT == MVT::i16 || Op0VT == MVT::i32 ||
+       (Subtarget->is64Bit() && Op0VT == MVT::i64))) {
----------------
s-barannikov wrote:

With the above suggestion, check for i16 is redundant since it is an illegal type.

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


More information about the llvm-commits mailing list