diff --git a/llvm/test/Transforms/InstSimplify/icmp-constant.ll b/llvm/test/Transforms/InstSimplify/icmp-constant.ll --- a/llvm/test/Transforms/InstSimplify/icmp-constant.ll +++ b/llvm/test/Transforms/InstSimplify/icmp-constant.ll @@ -1140,3 +1140,64 @@ %c = icmp ult <2 x i8> %x, ret <2 x i1> %c } + + +define i1 @cmp_ne_0_is_false(i32 %x) { +; CHECK-LABEL: @cmp_ne_0_is_false( +; CHECK-NEXT: [[Y:%.*]] = add i32 [[X:%.*]], 1 +; CHECK-NEXT: [[Z:%.*]] = and i32 [[X]], [[Y]] +; CHECK-NEXT: [[B:%.*]] = and i32 [[Z]], 1 +; CHECK-NEXT: [[E:%.*]] = icmp ne i32 [[B]], 0 +; CHECK-NEXT: ret i1 [[E]] +; + %y = add i32 %x, 1 + %z = and i32 %x, %y + %b = and i32 %z, 1 + %e = icmp ne i32 %b, 0 + ret i1 %e +} + +define i1 @cmp_eq_0_is_true(i32 %x) { +; CHECK-LABEL: @cmp_eq_0_is_true( +; CHECK-NEXT: [[Y:%.*]] = add i32 [[X:%.*]], 1 +; CHECK-NEXT: [[Z:%.*]] = and i32 [[X]], [[Y]] +; CHECK-NEXT: [[B:%.*]] = and i32 [[Z]], 1 +; CHECK-NEXT: [[E:%.*]] = icmp eq i32 [[B]], 0 +; CHECK-NEXT: ret i1 [[E]] +; + %y = add i32 %x, 1 + %z = and i32 %x, %y + %b = and i32 %z, 1 + %e = icmp eq i32 %b, 0 + ret i1 %e +} + +define <2 x i1> @cmp_ule_0_is_true(<2 x i32> %x) { +; CHECK-LABEL: @cmp_ule_0_is_true( +; CHECK-NEXT: [[Y:%.*]] = add <2 x i32> [[X:%.*]], +; CHECK-NEXT: [[Z:%.*]] = and <2 x i32> [[X]], [[Y]] +; CHECK-NEXT: [[B:%.*]] = and <2 x i32> [[Z]], +; CHECK-NEXT: [[E:%.*]] = icmp ule <2 x i32> [[B]], zeroinitializer +; CHECK-NEXT: ret <2 x i1> [[E]] +; + %y = add <2 x i32> %x, + %z = and <2 x i32> %x, %y + %b = and <2 x i32> %z, + %e = icmp ule <2 x i32> %b, + ret <2 x i1> %e +} + +define <2 x i1> @cmp_ugt_0_is_false(<2 x i32> %x) { +; CHECK-LABEL: @cmp_ugt_0_is_false( +; CHECK-NEXT: [[Y:%.*]] = add <2 x i32> [[X:%.*]], +; CHECK-NEXT: [[Z:%.*]] = and <2 x i32> [[X]], [[Y]] +; CHECK-NEXT: [[B:%.*]] = and <2 x i32> [[Z]], +; CHECK-NEXT: [[E:%.*]] = icmp ugt <2 x i32> [[B]], zeroinitializer +; CHECK-NEXT: ret <2 x i1> [[E]] +; + %y = add <2 x i32> %x, + %z = and <2 x i32> %x, %y + %b = and <2 x i32> %z, + %e = icmp ugt <2 x i32> %b, + ret <2 x i1> %e +}