@@ -4567,7 +4567,6 @@ static SDValue foldSetCCWithRotate(EVT VT, SDValue N0, SDValue N1,
4567
4567
// or (rot X, Y), Z ==/!= 0 --> (or X, Z) ==/!= 0
4568
4568
// or Z, (rot X, Y) ==/!= 0 --> (or X, Z) ==/!= 0
4569
4569
//
4570
- // TODO: Add the 'and' with -1 sibling.
4571
4570
// TODO: Recurse through a series of 'or' ops to find the rotate.
4572
4571
EVT OpVT = N0.getValueType ();
4573
4572
if (N0.hasOneUse () && N0.getOpcode () == ISD::OR && C1->isZero ()) {
@@ -4581,6 +4580,21 @@ static SDValue foldSetCCWithRotate(EVT VT, SDValue N0, SDValue N1,
4581
4580
}
4582
4581
}
4583
4582
4583
+ // and (rot X, Y), Z ==/!= -1 --> (and X, Z) ==/!= -1
4584
+ // and Z, (rot X, Y) ==/!= -1 --> (and X, Z) ==/!= -1
4585
+ //
4586
+ // TODO: Recursively peek through a series of 'and' ops to find the rotate.
4587
+ if (N0.hasOneUse () && N0.getOpcode () == ISD::AND && C1->isAllOnes ()) {
4588
+ if (SDValue R = getRotateSource (N0.getOperand (0 ))) {
4589
+ SDValue NewAnd = DAG.getNode (ISD::AND, dl, OpVT, R, N0.getOperand (1 ));
4590
+ return DAG.getSetCC (dl, VT, NewAnd, N1, Cond);
4591
+ }
4592
+ if (SDValue R = getRotateSource (N0.getOperand (1 ))) {
4593
+ SDValue NewAnd = DAG.getNode (ISD::AND, dl, OpVT, R, N0.getOperand (0 ));
4594
+ return DAG.getSetCC (dl, VT, NewAnd, N1, Cond);
4595
+ }
4596
+ }
4597
+
4584
4598
return SDValue ();
4585
4599
}
4586
4600
0 commit comments