Constant *NotC = ConstantExpr::getNot(C);
return BinaryOperator::CreateAShr(NotC, Y);
}
+
+ // ~(X + C) --> -(C + 1) - X
+ if (match(Op0, m_Add(m_Value(X), m_Constant(C))))
+ return BinaryOperator::CreateSub(ConstantExpr::getNeg(AddOne(C)), X);
}
// not (cmp A, B) = !cmp A, B
return BinaryOperator::CreateSub(NewC, X);
}
} else if (match(Op0, m_Add(m_Value(X), m_APInt(C)))) {
- // ~(X + C) --> (-C - 1) - X
- if (RHSC->isAllOnesValue()) {
- Constant *NewC = ConstantInt::get(I.getType(), -(*C) - 1);
- return BinaryOperator::CreateSub(NewC, X);
- }
if (RHSC->isSignMask()) {
// (X + C) ^ signmask -> (X + C + signmask)
Constant *NewC = ConstantInt::get(I.getType(), *C + *RHSC);
define <2 x i32> @not_add_vec(<2 x i32> %x) {
; CHECK-LABEL: @not_add_vec(
-; CHECK-NEXT: [[A:%.*]] = add <2 x i32> [[X:%.*]], <i32 42, i32 123>
-; CHECK-NEXT: [[R:%.*]] = xor <2 x i32> [[A]], <i32 -1, i32 -1>
+; CHECK-NEXT: [[R:%.*]] = sub <2 x i32> <i32 -43, i32 -124>, [[X:%.*]]
; CHECK-NEXT: ret <2 x i32> [[R]]
;
%a = add <2 x i32> %x, <i32 42, i32 123>