// (sub C, X) == X, C is odd --> false
// (sub C, X) != X, C is odd --> true
- if (match(LBO, m_Sub(m_APInt(C), m_Specific(RHS)))) {
- if ((*C & 1) == 1) {
- if (Pred == CmpInst::ICMP_EQ)
- return getFalse(ITy);
- if (Pred == CmpInst::ICMP_NE)
- return getTrue(ITy);
- }
- }
+ if (match(LBO, m_Sub(m_APIntAllowUndef(C), m_Specific(RHS))) &&
+ (*C & 1) == 1 && ICmpInst::isEquality(Pred))
+ return (Pred == ICmpInst::ICMP_EQ) ? getFalse(ITy) : getTrue(ITy);
return nullptr;
}
define <2 x i1> @sub_odd_poison(<2 x i8> %x) {
; CHECK-LABEL: @sub_odd_poison(
-; CHECK-NEXT: [[SUB:%.*]] = sub <2 x i8> <i8 poison, i8 1>, [[X:%.*]]
-; CHECK-NEXT: [[CMP:%.*]] = icmp ne <2 x i8> [[SUB]], [[X]]
-; CHECK-NEXT: ret <2 x i1> [[CMP]]
+; CHECK-NEXT: ret <2 x i1> <i1 true, i1 true>
;
%sub = sub <2 x i8> <i8 poison, i8 1>, %x
%cmp = icmp ne <2 x i8> %sub, %x