forked from OSchip/llvm-project
[InstCombine] allow add+not --> sub for arbitrary vector constants.
llvm-svn: 341335
This commit is contained in:
parent
7a213d2f9b
commit
d75064e6d5
llvm
|
@ -2699,6 +2699,10 @@ Instruction *InstCombiner::visitXor(BinaryOperator &I) {
|
|||
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
|
||||
|
@ -2720,11 +2724,6 @@ Instruction *InstCombiner::visitXor(BinaryOperator &I) {
|
|||
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);
|
||||
|
|
|
@ -243,8 +243,7 @@ define <2 x i32> @not_add_splat(<2 x i32> %x) {
|
|||
|
||||
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>
|
||||
|
|
Loading…
Reference in New Issue