diff --git a/llvm/test/Transforms/InstSimplify/and-or-icmp-zero.ll b/llvm/test/Transforms/InstSimplify/and-or-icmp-zero.ll index eb1d05d1822c..3e50a5968b46 100644 --- a/llvm/test/Transforms/InstSimplify/and-or-icmp-zero.ll +++ b/llvm/test/Transforms/InstSimplify/and-or-icmp-zero.ll @@ -262,3 +262,29 @@ define i1 @and_cmps_ptr_eq_zero_with_mask_commute4(ptr %p, i64 %y) { ret i1 %r } +; tests from PR66606 +define i32 @and_zext_eq_zero(i32 %a) { +; CHECK-LABEL: @and_zext_eq_zero( +; CHECK-NEXT: [[COND:%.*]] = icmp eq i32 [[A:%.*]], 0 +; CHECK-NEXT: [[NOT:%.*]] = zext i1 [[COND]] to i32 +; CHECK-NEXT: [[R:%.*]] = and i32 [[A]], [[NOT]] +; CHECK-NEXT: ret i32 [[R]] +; + %cond = icmp eq i32 %a, 0 + %not = zext i1 %cond to i32 + %r = and i32 %a, %not + ret i32 %r +} + +define i32 @and_zext_eq_zero_commuted(i32 %a) { +; CHECK-LABEL: @and_zext_eq_zero_commuted( +; CHECK-NEXT: [[COND:%.*]] = icmp eq i32 [[A:%.*]], 0 +; CHECK-NEXT: [[NOT:%.*]] = zext i1 [[COND]] to i32 +; CHECK-NEXT: [[R:%.*]] = and i32 [[NOT]], [[A]] +; CHECK-NEXT: ret i32 [[R]] +; + %cond = icmp eq i32 %a, 0 + %not = zext i1 %cond to i32 + %r = and i32 %not, %a + ret i32 %r +}