if (N->getValueType(0) != MVT::i32 || !isNullConstant(N->getOperand(0)))
return SDValue();
SDValue CSINC = N->getOperand(1);
- if (CSINC.getOpcode() != ARMISD::CSINC)
+ if (CSINC.getOpcode() != ARMISD::CSINC || !CSINC.hasOneUse())
return SDValue();
ConstantSDNode *X = dyn_cast<ConstantSDNode>(CSINC.getOperand(0));
ret i32 %xor
}
+define i32 @csinc_to_csinv(i32 %a) {
+; CHECK-LABEL: csinc_to_csinv:
+; CHECK: @ %bb.0: @ %entry
+; CHECK-NEXT: cmp r0, #46
+; CHECK-NEXT: csetm r0, lt
+; CHECK-NEXT: bx lr
+entry:
+ %cmp = icmp sgt i32 %a, 45
+ %spec.select = select i1 %cmp, i32 0, i32 1
+ %s = sub i32 0, %spec.select
+ ret i32 %s
+}
+
+define i32 @csinc_to_csinv_multi(i32 %a) {
+; CHECK-LABEL: csinc_to_csinv_multi:
+; CHECK: @ %bb.0: @ %entry
+; CHECK-NEXT: cmp r0, #46
+; CHECK-NEXT: cset r0, lt
+; CHECK-NEXT: rsbs r1, r0, #0
+; CHECK-NEXT: eors r0, r1
+; CHECK-NEXT: bx lr
+entry:
+ %cmp = icmp sgt i32 %a, 45
+ %spec.select = select i1 %cmp, i32 0, i32 1
+ %s = sub i32 0, %spec.select
+ %t = xor i32 %s, %spec.select
+ ret i32 %t
+}