Skip to content

Commit

Permalink
[InstCombine] fix icmp with not op and constant to work with splat ve…
Browse files Browse the repository at this point in the history
…ctor constant

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@304562 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
rotateright committed Jun 2, 2017
1 parent afe7c5a commit 448aa4e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
6 changes: 3 additions & 3 deletions lib/Transforms/InstCombine/InstCombineCompares.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4514,10 +4514,10 @@ Instruction *InstCombiner::visitICmpInst(ICmpInst &I) {
if (match(Op1, m_Not(m_Value(B))))
return new ICmpInst(I.getPredicate(), B, A);

// FIXME: Use m_APInt to include splat vector constants.
if (ConstantInt *RHSC = dyn_cast<ConstantInt>(Op1))
const APInt *C;
if (match(Op1, m_APInt(C)))
return new ICmpInst(I.getSwappedPredicate(), A,
ConstantExpr::getNot(RHSC));
ConstantInt::get(Op1->getType(), ~(*C)));
}

Instruction *AddI = nullptr;
Expand Down
3 changes: 1 addition & 2 deletions test/Transforms/InstCombine/not.ll
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ define i1 @not_cmp_constant(i32 %a) {

define <2 x i1> @not_cmp_constant_vector(<2 x i32> %a) {
; CHECK-LABEL: @not_cmp_constant_vector(
; CHECK-NEXT: [[NOTA:%.*]] = xor <2 x i32> %a, <i32 -1, i32 -1>
; CHECK-NEXT: [[CMP:%.*]] = icmp slt <2 x i32> [[NOTA]], <i32 42, i32 42>
; CHECK-NEXT: [[CMP:%.*]] = icmp sgt <2 x i32> %a, <i32 -43, i32 -43>
; CHECK-NEXT: ret <2 x i1> [[CMP]]
;
%nota = xor <2 x i32> %a, <i32 -1, i32 -1>
Expand Down

0 comments on commit 448aa4e

Please sign in to comment.