Skip to content

Commit a93afa0

Browse files
committed
Fix rotation
1 parent 2cee8e2 commit a93afa0

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9897,19 +9897,19 @@ SDValue TargetLowering::expandBSWAP(SDNode *N, SelectionDAG &DAG) const {
98979897
return SDValue();
98989898
case MVT::i16:
98999899
// Use a rotate by 8. This can be further expanded if necessary.
9900-
return DAG.getNode(ISD::ROTL, dl, VT, Op, DAG.getConstant(8, dl, SHVT));
9900+
return DAG.getNode(ISD::ROTR, dl, VT, Op, DAG.getConstant(8, dl, SHVT));
99019901
case MVT::i32:
99029902
if (isOperationLegal(ISD::ROTR, VT)) {
9903-
// (x & 0x00FF00FF) rotl 8 | (x rotr 8) & 0x00FF00FF
9903+
// (x & 0x00FF00FF) rotr 8 | (x rotl 8) & 0x00FF00FF
99049904
SDValue And = DAG.getNode(ISD::AND, dl, VT, Op,
99059905
DAG.getConstant(0x00FF00FF, dl, VT));
9906-
SDValue Rotl =
9907-
DAG.getNode(ISD::ROTL, dl, VT, And, DAG.getConstant(8, dl, SHVT));
99089906
SDValue Rotr =
9909-
DAG.getNode(ISD::ROTR, dl, VT, Op, DAG.getConstant(8, dl, SHVT));
9910-
SDValue And2 = DAG.getNode(ISD::AND, dl, VT, Rotr,
9907+
DAG.getNode(ISD::ROTR, dl, VT, And, DAG.getConstant(8, dl, SHVT));
9908+
SDValue Rotl =
9909+
DAG.getNode(ISD::ROTL, dl, VT, Op, DAG.getConstant(8, dl, SHVT));
9910+
SDValue And2 = DAG.getNode(ISD::AND, dl, VT, Rotl,
99119911
DAG.getConstant(0x00FF00FF, dl, VT));
9912-
return DAG.getNode(ISD::OR, dl, VT, Rotl, And2);
9912+
return DAG.getNode(ISD::OR, dl, VT, Rotr, And2);
99139913
}
99149914
Tmp4 = DAG.getNode(ISD::SHL, dl, VT, Op, DAG.getConstant(24, dl, SHVT));
99159915
Tmp3 = DAG.getNode(ISD::AND, dl, VT, Op,

0 commit comments

Comments
 (0)