@@ -10553,29 +10553,20 @@ static SDValue foldBitOrderCrossLogicOp(SDNode *N, SelectionDAG &DAG) {
1055310553 SDValue N0 = N->getOperand(0);
1055410554 EVT VT = N->getValueType(0);
1055510555 SDLoc DL(N);
10556+ SDValue X, Y;
1055610557
10557- SDValue OldLHS, OldRHS;
10558- if (sd_match(N0,
10559- m_OneUse(m_BitwiseLogic(m_Value(OldLHS), m_Value(OldRHS))))) {
10560- // If both operands are bswap/bitreverse, ignore the multiuse
10561- // Otherwise need to ensure logic_op and bswap/bitreverse(x) have one use.
10562- if (OldLHS.getOpcode() == Opcode && OldRHS.getOpcode() == Opcode) {
10563- return DAG.getNode(N0.getOpcode(), DL, VT, OldLHS.getOperand(0),
10564- OldRHS.getOperand(0));
10565- }
10558+ // If both operands are bswap/bitreverse, ignore the multiuse
10559+ if (sd_match(N0, m_OneUse(m_BitwiseLogic(m_UnaryOp(Opcode, m_Value(X)),
10560+ m_UnaryOp(Opcode, m_Value(Y))))))
10561+ return DAG.getNode(N0.getOpcode(), DL, VT, X, Y);
1056610562
10567- if (OldLHS.getOpcode() == Opcode && OldLHS.hasOneUse()) {
10568- SDValue NewBitReorder = DAG.getNode(Opcode, DL, VT, OldRHS);
10569- return DAG.getNode(N0.getOpcode(), DL, VT, OldLHS.getOperand(0),
10570- NewBitReorder);
10571- }
10572-
10573- if (OldRHS.getOpcode() == Opcode && OldRHS.hasOneUse()) {
10574- SDValue NewBitReorder = DAG.getNode(Opcode, DL, VT, OldLHS);
10575- return DAG.getNode(N0.getOpcode(), DL, VT, NewBitReorder,
10576- OldRHS.getOperand(0));
10577- }
10563+ // Otherwise need to ensure logic_op and bswap/bitreverse(x) have one use.
10564+ if (sd_match(N0, m_OneUse(m_BitwiseLogic(
10565+ m_OneUse(m_UnaryOp(Opcode, m_Value(X))), m_Value(Y))))) {
10566+ SDValue NewBitReorder = DAG.getNode(Opcode, DL, VT, Y);
10567+ return DAG.getNode(N0.getOpcode(), DL, VT, X, NewBitReorder);
1057810568 }
10569+
1057910570 return SDValue();
1058010571}
1058110572
0 commit comments