[llvm] [DAGCombine] Improve bswap lowering for machines that support bit rotates (PR #164848)
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 24 00:50:41 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)) {
+ // (x & 0x00FF00FF) rotl 8 | (x rotr 8) & 0x00FF00FF
+ SDValue And = DAG.getNode(ISD::AND, dl, VT, Op,
----------------
RKSimon wrote:
Pull out repeated and mask constant
https://github.com/llvm/llvm-project/pull/164848
More information about the llvm-commits
mailing list