[llvm] [DAGCombine] Improve bswap lowering for machines that support bit rotates (PR #164848)

via llvm-commits llvm-commits at lists.llvm.org
Sat Oct 25 07:47:08 PDT 2025


================
@@ -9899,6 +9899,18 @@ SDValue TargetLowering::expandBSWAP(SDNode *N, SelectionDAG &DAG) const {
     // Use a rotate by 8. This can be further expanded if necessary.
     return DAG.getNode(ISD::ROTL, dl, VT, Op, DAG.getConstant(8, dl, SHVT));
   case MVT::i32:
+    if (isOperationLegal(ISD::ROTR, VT)) {
----------------
AZero13 wrote:

I feel like legal is best here. I don't know anywhere that has custom for rotr though but sure I guess.

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


More information about the llvm-commits mailing list