const APInt &AndRHSC = AndRHS->getAPIntValue();
if ((-AndRHSC).isPowerOf2() && (AndRHSC & C1) == C1) {
unsigned ShiftBits = AndRHSC.countTrailingZeros();
- SDValue Shift = DAG.getNode(ISD::SRL, dl, ShValTy, N0.getOperand(0),
- DAG.getConstant(ShiftBits, dl,
- ShiftTy));
- SDValue CmpRHS = DAG.getConstant(C1.lshr(ShiftBits), dl, ShValTy);
- return DAG.getSetCC(dl, VT, Shift, CmpRHS, Cond);
+ if (ShiftBits <= TLI.getShiftAmountThreshold(ShValTy)) {
+ SDValue Shift =
+ DAG.getNode(ISD::SRL, dl, ShValTy, N0.getOperand(0),
+ DAG.getConstant(ShiftBits, dl, ShiftTy));
+ SDValue CmpRHS = DAG.getConstant(C1.lshr(ShiftBits), dl, ShValTy);
+ return DAG.getSetCC(dl, VT, Shift, CmpRHS, Cond);
+ }
}
}
} else if (Cond == ISD::SETULT || Cond == ISD::SETUGE ||
}
NewC.lshrInPlace(ShiftBits);
if (ShiftBits && NewC.getMinSignedBits() <= 64 &&
- isLegalICmpImmediate(NewC.getSExtValue())) {
+ isLegalICmpImmediate(NewC.getSExtValue()) &&
+ ShiftBits <= TLI.getShiftAmountThreshold(ShValTy)) {
SDValue Shift = DAG.getNode(ISD::SRL, dl, ShValTy, N0,
DAG.getConstant(ShiftBits, dl, ShiftTy));
SDValue CmpRHS = DAG.getConstant(NewC, dl, ShValTy);
define i16 @testSimplifySetCC_2(i16 %x) {
; CHECK-LABEL: testSimplifySetCC_2:
; CHECK: ; %bb.0: ; %entry
-; CHECK-NEXT: clrc
-; CHECK-NEXT: rrc r12
-; CHECK-NEXT: rra r12
-; CHECK-NEXT: rra r12
-; CHECK-NEXT: rra r12
-; CHECK-NEXT: rra r12
-; CHECK-NEXT: rra r12
-; CHECK-NEXT: cmp #1, r12
+; CHECK-NEXT: and #-64, r12
+; CHECK-NEXT: cmp #64, r12
; CHECK-NEXT: mov r2, r12
; CHECK-NEXT: rra r12
; CHECK-NEXT: and #1, r12
define i16 @testSimplifySetCC_3(i16 %x) {
; CHECK-LABEL: testSimplifySetCC_3:
; CHECK: ; %bb.0: ; %entry
-; CHECK-NEXT: clrc
-; CHECK-NEXT: rrc r12
-; CHECK-NEXT: rra r12
-; CHECK-NEXT: rra r12
-; CHECK-NEXT: rra r12
-; CHECK-NEXT: rra r12
-; CHECK-NEXT: rra r12
-; CHECK-NEXT: tst r12
-; CHECK-NEXT: mov r2, r13
-; CHECK-NEXT: rra r13
-; CHECK-NEXT: mov #1, r12
-; CHECK-NEXT: bic r13, r12
+; CHECK-NEXT: cmp #64, r12
+; CHECK-NEXT: mov r2, r12
+; CHECK-NEXT: and #1, r12
; CHECK-NEXT: ret
entry:
%cmp = icmp ugt i16 %x, 63
define i16 @testSimplifySetCC_4(i16 %x) {
; CHECK-LABEL: testSimplifySetCC_4:
; CHECK: ; %bb.0: ; %entry
-; CHECK-NEXT: clrc
-; CHECK-NEXT: rrc r12
-; CHECK-NEXT: rra r12
-; CHECK-NEXT: rra r12
-; CHECK-NEXT: rra r12
-; CHECK-NEXT: rra r12
-; CHECK-NEXT: rra r12
-; CHECK-NEXT: tst r12
-; CHECK-NEXT: mov r2, r12
-; CHECK-NEXT: rra r12
-; CHECK-NEXT: and #1, r12
+; CHECK-NEXT: cmp #64, r12
+; CHECK-NEXT: mov #1, r12
+; CHECK-NEXT: bic r2, r12
; CHECK-NEXT: ret
entry:
%cmp = icmp ult i16 %x, 64