// 0 - (zext X) pred C
if (!CmpInst::isUnsigned(Pred) && match(LHS, m_Neg(m_ZExt(m_Value())))) {
- if (ConstantInt *RHSC = dyn_cast<ConstantInt>(RHS)) {
- if (RHSC->getValue().isStrictlyPositive()) {
- if (Pred == ICmpInst::ICMP_SLT)
- return ConstantInt::getTrue(RHSC->getContext());
- if (Pred == ICmpInst::ICMP_SGE)
- return ConstantInt::getFalse(RHSC->getContext());
- if (Pred == ICmpInst::ICMP_EQ)
- return ConstantInt::getFalse(RHSC->getContext());
- if (Pred == ICmpInst::ICMP_NE)
- return ConstantInt::getTrue(RHSC->getContext());
+ const APInt *C;
+ if (match(RHS, m_APInt(C))) {
+ if (C->isStrictlyPositive()) {
+ if (Pred == ICmpInst::ICMP_SLT || Pred == ICmpInst::ICMP_NE)
+ return ConstantInt::getTrue(GetCompareTy(RHS));
+ if (Pred == ICmpInst::ICMP_SGE || Pred == ICmpInst::ICMP_EQ)
+ return ConstantInt::getFalse(GetCompareTy(RHS));
}
- if (RHSC->getValue().isNonNegative()) {
+ if (C->isNonNegative()) {
if (Pred == ICmpInst::ICMP_SLE)
- return ConstantInt::getTrue(RHSC->getContext());
+ return ConstantInt::getTrue(GetCompareTy(RHS));
if (Pred == ICmpInst::ICMP_SGT)
- return ConstantInt::getFalse(RHSC->getContext());
+ return ConstantInt::getFalse(GetCompareTy(RHS));
}
}
}
define <2 x i1> @compare_always_true_slt_splat(<2 x i16> %a) {
; CHECK-LABEL: @compare_always_true_slt_splat(
-; CHECK-NEXT: [[T1:%.*]] = zext <2 x i16> [[A:%.*]] to <2 x i32>
-; CHECK-NEXT: [[T2:%.*]] = sub <2 x i32> zeroinitializer, [[T1]]
-; CHECK-NEXT: [[T3:%.*]] = icmp slt <2 x i32> [[T2]], <i32 1, i32 1>
-; CHECK-NEXT: ret <2 x i1> [[T3]]
+; CHECK-NEXT: ret <2 x i1> <i1 true, i1 true>
;
%t1 = zext <2 x i16> %a to <2 x i32>
%t2 = sub <2 x i32> zeroinitializer, %t1
define <2 x i1> @compare_always_true_sle_splat(<2 x i16> %a) {
; CHECK-LABEL: @compare_always_true_sle_splat(
-; CHECK-NEXT: [[T1:%.*]] = zext <2 x i16> [[A:%.*]] to <2 x i32>
-; CHECK-NEXT: [[T2:%.*]] = sub <2 x i32> zeroinitializer, [[T1]]
-; CHECK-NEXT: [[T3:%.*]] = icmp sle <2 x i32> [[T2]], zeroinitializer
-; CHECK-NEXT: ret <2 x i1> [[T3]]
+; CHECK-NEXT: ret <2 x i1> <i1 true, i1 true>
;
%t1 = zext <2 x i16> %a to <2 x i32>
%t2 = sub <2 x i32> zeroinitializer, %t1
define <2 x i1> @compare_always_false_sgt_splat(<2 x i16> %a) {
; CHECK-LABEL: @compare_always_false_sgt_splat(
-; CHECK-NEXT: [[T1:%.*]] = zext <2 x i16> [[A:%.*]] to <2 x i32>
-; CHECK-NEXT: [[T2:%.*]] = sub <2 x i32> zeroinitializer, [[T1]]
-; CHECK-NEXT: [[T3:%.*]] = icmp sgt <2 x i32> [[T2]], zeroinitializer
-; CHECK-NEXT: ret <2 x i1> [[T3]]
+; CHECK-NEXT: ret <2 x i1> zeroinitializer
;
%t1 = zext <2 x i16> %a to <2 x i32>
%t2 = sub <2 x i32> zeroinitializer, %t1
define <2 x i1> @compare_always_false_sge_splat(<2 x i16> %a) {
; CHECK-LABEL: @compare_always_false_sge_splat(
-; CHECK-NEXT: [[T1:%.*]] = zext <2 x i16> [[A:%.*]] to <2 x i32>
-; CHECK-NEXT: [[T2:%.*]] = sub <2 x i32> zeroinitializer, [[T1]]
-; CHECK-NEXT: [[T3:%.*]] = icmp sge <2 x i32> [[T2]], <i32 1, i32 1>
-; CHECK-NEXT: ret <2 x i1> [[T3]]
+; CHECK-NEXT: ret <2 x i1> zeroinitializer
;
%t1 = zext <2 x i16> %a to <2 x i32>
%t2 = sub <2 x i32> zeroinitializer, %t1
define <2 x i1> @compare_always_false_eq_splat(<2 x i16> %a) {
; CHECK-LABEL: @compare_always_false_eq_splat(
-; CHECK-NEXT: [[T1:%.*]] = zext <2 x i16> [[A:%.*]] to <2 x i32>
-; CHECK-NEXT: [[T2:%.*]] = sub <2 x i32> zeroinitializer, [[T1]]
-; CHECK-NEXT: [[T3:%.*]] = icmp eq <2 x i32> [[T2]], <i32 1, i32 1>
-; CHECK-NEXT: ret <2 x i1> [[T3]]
+; CHECK-NEXT: ret <2 x i1> zeroinitializer
;
%t1 = zext <2 x i16> %a to <2 x i32>
%t2 = sub <2 x i32> zeroinitializer, %t1
define <2 x i1> @compare_always_true_ne_splat(<2 x i16> %a) {
; CHECK-LABEL: @compare_always_true_ne_splat(
-; CHECK-NEXT: [[T1:%.*]] = zext <2 x i16> [[A:%.*]] to <2 x i32>
-; CHECK-NEXT: [[T2:%.*]] = sub <2 x i32> zeroinitializer, [[T1]]
-; CHECK-NEXT: [[T3:%.*]] = icmp ne <2 x i32> [[T2]], <i32 1, i32 1>
-; CHECK-NEXT: ret <2 x i1> [[T3]]
+; CHECK-NEXT: ret <2 x i1> <i1 true, i1 true>
;
%t1 = zext <2 x i16> %a to <2 x i32>
%t2 = sub <2 x i32> zeroinitializer, %t1