diff --git a/lib/Transforms/InstCombine/InstCombineCompares.cpp b/lib/Transforms/InstCombine/InstCombineCompares.cpp index 4ca967d3afb4..c0798e164c39 100644 --- a/lib/Transforms/InstCombine/InstCombineCompares.cpp +++ b/lib/Transforms/InstCombine/InstCombineCompares.cpp @@ -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(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; diff --git a/test/Transforms/InstCombine/not.ll b/test/Transforms/InstCombine/not.ll index b52919071d20..8352c07a816b 100644 --- a/test/Transforms/InstCombine/not.ll +++ b/test/Transforms/InstCombine/not.ll @@ -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, -; CHECK-NEXT: [[CMP:%.*]] = icmp slt <2 x i32> [[NOTA]], +; CHECK-NEXT: [[CMP:%.*]] = icmp sgt <2 x i32> %a, ; CHECK-NEXT: ret <2 x i1> [[CMP]] ; %nota = xor <2 x i32> %a,