From 1c345c1873c388c964f567a0ef113c9bb7b6e458 Mon Sep 17 00:00:00 2001 From: "chenglin.bi" Date: Tue, 7 Feb 2023 12:08:36 +0800 Subject: [PATCH] [Instcombine] Precommit tests for D143373; NFC --- llvm/test/Transforms/InstCombine/icmp-range.ll | 124 +++++++++++++++---------- 1 file changed, 76 insertions(+), 48 deletions(-) diff --git a/llvm/test/Transforms/InstCombine/icmp-range.ll b/llvm/test/Transforms/InstCombine/icmp-range.ll index 99d8e7e..1b075dd 100644 --- a/llvm/test/Transforms/InstCombine/icmp-range.ll +++ b/llvm/test/Transforms/InstCombine/icmp-range.ll @@ -632,14 +632,14 @@ define i1 @ashr_uge_sub(i8 %b, i8 %x, i8 %y) { define i1 @zext_sext_add_icmp_eq_minus1(i1 %a, i1 %b) { ; CHECK-LABEL: @zext_sext_add_icmp_eq_minus1( ; CHECK-NEXT: [[ZEXT_A:%.*]] = zext i1 [[A:%.*]] to i8 -; CHECK-NEXT: [[ZEXT_B:%.*]] = sext i1 [[B:%.*]] to i8 -; CHECK-NEXT: [[ADD:%.*]] = add nsw i8 [[ZEXT_A]], [[ZEXT_B]] +; CHECK-NEXT: [[SEXT_B:%.*]] = sext i1 [[B:%.*]] to i8 +; CHECK-NEXT: [[ADD:%.*]] = add nsw i8 [[ZEXT_A]], [[SEXT_B]] ; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[ADD]], -1 ; CHECK-NEXT: ret i1 [[R]] ; %zext.a = zext i1 %a to i8 - %zext.b = sext i1 %b to i8 - %add = add i8 %zext.a, %zext.b + %sext.b = sext i1 %b to i8 + %add = add i8 %zext.a, %sext.b %r = icmp eq i8 %add, -1 ret i1 %r } @@ -647,14 +647,14 @@ define i1 @zext_sext_add_icmp_eq_minus1(i1 %a, i1 %b) { define i1 @zext_sext_add_icmp_ne_minus1(i1 %a, i1 %b) { ; CHECK-LABEL: @zext_sext_add_icmp_ne_minus1( ; CHECK-NEXT: [[ZEXT_A:%.*]] = zext i1 [[A:%.*]] to i8 -; CHECK-NEXT: [[ZEXT_B:%.*]] = sext i1 [[B:%.*]] to i8 -; CHECK-NEXT: [[ADD:%.*]] = add nsw i8 [[ZEXT_A]], [[ZEXT_B]] +; CHECK-NEXT: [[SEXT_B:%.*]] = sext i1 [[B:%.*]] to i8 +; CHECK-NEXT: [[ADD:%.*]] = add nsw i8 [[ZEXT_A]], [[SEXT_B]] ; CHECK-NEXT: [[R:%.*]] = icmp ne i8 [[ADD]], -1 ; CHECK-NEXT: ret i1 [[R]] ; %zext.a = zext i1 %a to i8 - %zext.b = sext i1 %b to i8 - %add = add i8 %zext.a, %zext.b + %sext.b = sext i1 %b to i8 + %add = add i8 %zext.a, %sext.b %r = icmp ne i8 %add, -1 ret i1 %r } @@ -666,23 +666,38 @@ define i1 @zext_sext_add_icmp_sgt_minus1(i1 %a, i1 %b) { ; CHECK-NEXT: ret i1 [[R]] ; %zext.a = zext i1 %a to i8 - %zext.b = sext i1 %b to i8 - %add = add i8 %zext.a, %zext.b + %sext.b = sext i1 %b to i8 + %add = add i8 %zext.a, %sext.b %r = icmp sgt i8 %add, -1 ret i1 %r } +define i1 @zext_sext_add_icmp_ult_minus1(i1 %a, i1 %b) { +; CHECK-LABEL: @zext_sext_add_icmp_ult_minus1( +; CHECK-NEXT: [[ZEXT_A:%.*]] = zext i1 [[A:%.*]] to i8 +; CHECK-NEXT: [[SEXT_B:%.*]] = sext i1 [[B:%.*]] to i8 +; CHECK-NEXT: [[ADD:%.*]] = add nsw i8 [[ZEXT_A]], [[SEXT_B]] +; CHECK-NEXT: [[R:%.*]] = icmp ne i8 [[ADD]], -1 +; CHECK-NEXT: ret i1 [[R]] +; + %zext.a = zext i1 %a to i8 + %sext.b = sext i1 %b to i8 + %add = add i8 %zext.a, %sext.b + %r = icmp ult i8 %add, -1 + ret i1 %r +} + define i1 @zext_sext_add_icmp_sgt_0(i1 %a, i1 %b) { ; CHECK-LABEL: @zext_sext_add_icmp_sgt_0( ; CHECK-NEXT: [[ZEXT_A:%.*]] = zext i1 [[A:%.*]] to i8 -; CHECK-NEXT: [[ZEXT_B:%.*]] = sext i1 [[B:%.*]] to i8 -; CHECK-NEXT: [[ADD:%.*]] = add nsw i8 [[ZEXT_A]], [[ZEXT_B]] +; CHECK-NEXT: [[SEXT_B:%.*]] = sext i1 [[B:%.*]] to i8 +; CHECK-NEXT: [[ADD:%.*]] = add nsw i8 [[ZEXT_A]], [[SEXT_B]] ; CHECK-NEXT: [[R:%.*]] = icmp sgt i8 [[ADD]], 0 ; CHECK-NEXT: ret i1 [[R]] ; %zext.a = zext i1 %a to i8 - %zext.b = sext i1 %b to i8 - %add = add i8 %zext.a, %zext.b + %sext.b = sext i1 %b to i8 + %add = add i8 %zext.a, %sext.b %r = icmp sgt i8 %add, 0 ret i1 %r } @@ -694,8 +709,8 @@ define i1 @zext_sext_add_icmp_slt_0(i1 %a, i1 %b) { ; CHECK-NEXT: ret i1 [[TMP2]] ; %zext.a = zext i1 %a to i8 - %zext.b = sext i1 %b to i8 - %add = add i8 %zext.a, %zext.b + %sext.b = sext i1 %b to i8 + %add = add i8 %zext.a, %sext.b %r = icmp slt i8 %add, 0 ret i1 %r } @@ -703,14 +718,14 @@ define i1 @zext_sext_add_icmp_slt_0(i1 %a, i1 %b) { define i1 @zext_sext_add_icmp_eq_1(i1 %a, i1 %b) { ; CHECK-LABEL: @zext_sext_add_icmp_eq_1( ; CHECK-NEXT: [[ZEXT_A:%.*]] = zext i1 [[A:%.*]] to i8 -; CHECK-NEXT: [[ZEXT_B:%.*]] = sext i1 [[B:%.*]] to i8 -; CHECK-NEXT: [[ADD:%.*]] = add nsw i8 [[ZEXT_A]], [[ZEXT_B]] +; CHECK-NEXT: [[SEXT_B:%.*]] = sext i1 [[B:%.*]] to i8 +; CHECK-NEXT: [[ADD:%.*]] = add nsw i8 [[ZEXT_A]], [[SEXT_B]] ; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[ADD]], 1 ; CHECK-NEXT: ret i1 [[R]] ; %zext.a = zext i1 %a to i8 - %zext.b = sext i1 %b to i8 - %add = add i8 %zext.a, %zext.b + %sext.b = sext i1 %b to i8 + %add = add i8 %zext.a, %sext.b %r = icmp eq i8 %add, 1 ret i1 %r } @@ -718,14 +733,14 @@ define i1 @zext_sext_add_icmp_eq_1(i1 %a, i1 %b) { define i1 @zext_sext_add_icmp_ne_1(i1 %a, i1 %b) { ; CHECK-LABEL: @zext_sext_add_icmp_ne_1( ; CHECK-NEXT: [[ZEXT_A:%.*]] = zext i1 [[A:%.*]] to i8 -; CHECK-NEXT: [[ZEXT_B:%.*]] = sext i1 [[B:%.*]] to i8 -; CHECK-NEXT: [[ADD:%.*]] = add nsw i8 [[ZEXT_A]], [[ZEXT_B]] +; CHECK-NEXT: [[SEXT_B:%.*]] = sext i1 [[B:%.*]] to i8 +; CHECK-NEXT: [[ADD:%.*]] = add nsw i8 [[ZEXT_A]], [[SEXT_B]] ; CHECK-NEXT: [[R:%.*]] = icmp ne i8 [[ADD]], 1 ; CHECK-NEXT: ret i1 [[R]] ; %zext.a = zext i1 %a to i8 - %zext.b = sext i1 %b to i8 - %add = add i8 %zext.a, %zext.b + %sext.b = sext i1 %b to i8 + %add = add i8 %zext.a, %sext.b %r = icmp ne i8 %add, 1 ret i1 %r } @@ -733,29 +748,42 @@ define i1 @zext_sext_add_icmp_ne_1(i1 %a, i1 %b) { define i1 @zext_sext_add_icmp_slt_1(i1 %a, i1 %b) { ; CHECK-LABEL: @zext_sext_add_icmp_slt_1( ; CHECK-NEXT: [[ZEXT_A:%.*]] = zext i1 [[A:%.*]] to i8 -; CHECK-NEXT: [[ZEXT_B:%.*]] = sext i1 [[B:%.*]] to i8 -; CHECK-NEXT: [[ADD:%.*]] = add nsw i8 [[ZEXT_A]], [[ZEXT_B]] +; CHECK-NEXT: [[SEXT_B:%.*]] = sext i1 [[B:%.*]] to i8 +; CHECK-NEXT: [[ADD:%.*]] = add nsw i8 [[ZEXT_A]], [[SEXT_B]] ; CHECK-NEXT: [[R:%.*]] = icmp slt i8 [[ADD]], 1 ; CHECK-NEXT: ret i1 [[R]] ; %zext.a = zext i1 %a to i8 - %zext.b = sext i1 %b to i8 - %add = add i8 %zext.a, %zext.b + %sext.b = sext i1 %b to i8 + %add = add i8 %zext.a, %sext.b %r = icmp slt i8 %add, 1 ret i1 %r } +define i1 @zext_sext_add_icmp_ugt_1(i1 %a, i1 %b) { +; CHECK-LABEL: @zext_sext_add_icmp_ugt_1( +; CHECK-NEXT: [[TMP1:%.*]] = xor i1 [[A:%.*]], true +; CHECK-NEXT: [[TMP2:%.*]] = and i1 [[TMP1]], [[B:%.*]] +; CHECK-NEXT: ret i1 [[TMP2]] +; + %zext.a = zext i1 %a to i8 + %sext.b = sext i1 %b to i8 + %add = add i8 %zext.a, %sext.b + %r = icmp ugt i8 %add, 1 + ret i1 %r +} + define <2 x i1> @vector_zext_sext_add_icmp_slt_1(<2 x i1> %a, <2 x i1> %b) { ; CHECK-LABEL: @vector_zext_sext_add_icmp_slt_1( ; CHECK-NEXT: [[ZEXT_A:%.*]] = zext <2 x i1> [[A:%.*]] to <2 x i8> -; CHECK-NEXT: [[ZEXT_B:%.*]] = sext <2 x i1> [[B:%.*]] to <2 x i8> -; CHECK-NEXT: [[ADD:%.*]] = add nsw <2 x i8> [[ZEXT_A]], [[ZEXT_B]] +; CHECK-NEXT: [[SEXT_B:%.*]] = sext <2 x i1> [[B:%.*]] to <2 x i8> +; CHECK-NEXT: [[ADD:%.*]] = add nsw <2 x i8> [[ZEXT_A]], [[SEXT_B]] ; CHECK-NEXT: [[R:%.*]] = icmp slt <2 x i8> [[ADD]], ; CHECK-NEXT: ret <2 x i1> [[R]] ; %zext.a = zext <2 x i1> %a to <2 x i8> - %zext.b = sext <2 x i1> %b to <2 x i8> - %add = add <2 x i8> %zext.a, %zext.b + %sext.b = sext <2 x i1> %b to <2 x i8> + %add = add <2 x i8> %zext.a, %sext.b %r = icmp slt <2 x i8> %add, ret <2 x i1> %r } @@ -763,14 +791,14 @@ define <2 x i1> @vector_zext_sext_add_icmp_slt_1(<2 x i1> %a, <2 x i1> %b) { define <2 x i1> @vector_zext_sext_add_icmp_slt_1_poison(<2 x i1> %a, <2 x i1> %b) { ; CHECK-LABEL: @vector_zext_sext_add_icmp_slt_1_poison( ; CHECK-NEXT: [[ZEXT_A:%.*]] = zext <2 x i1> [[A:%.*]] to <2 x i8> -; CHECK-NEXT: [[ZEXT_B:%.*]] = sext <2 x i1> [[B:%.*]] to <2 x i8> -; CHECK-NEXT: [[ADD:%.*]] = add nsw <2 x i8> [[ZEXT_A]], [[ZEXT_B]] +; CHECK-NEXT: [[SEXT_B:%.*]] = sext <2 x i1> [[B:%.*]] to <2 x i8> +; CHECK-NEXT: [[ADD:%.*]] = add nsw <2 x i8> [[ZEXT_A]], [[SEXT_B]] ; CHECK-NEXT: [[R:%.*]] = icmp slt <2 x i8> [[ADD]], ; CHECK-NEXT: ret <2 x i1> [[R]] ; %zext.a = zext <2 x i1> %a to <2 x i8> - %zext.b = sext <2 x i1> %b to <2 x i8> - %add = add <2 x i8> %zext.a, %zext.b + %sext.b = sext <2 x i1> %b to <2 x i8> + %add = add <2 x i8> %zext.a, %sext.b %r = icmp slt <2 x i8> %add, ret <2 x i1> %r } @@ -778,15 +806,15 @@ define <2 x i1> @vector_zext_sext_add_icmp_slt_1_poison(<2 x i1> %a, <2 x i1> %b define i1 @zext_sext_add_icmp_slt_1_no_oneuse(i1 %a, i1 %b) { ; CHECK-LABEL: @zext_sext_add_icmp_slt_1_no_oneuse( ; CHECK-NEXT: [[ZEXT_A:%.*]] = zext i1 [[A:%.*]] to i8 -; CHECK-NEXT: [[ZEXT_B:%.*]] = sext i1 [[B:%.*]] to i8 -; CHECK-NEXT: [[ADD:%.*]] = add nsw i8 [[ZEXT_A]], [[ZEXT_B]] +; CHECK-NEXT: [[SEXT_B:%.*]] = sext i1 [[B:%.*]] to i8 +; CHECK-NEXT: [[ADD:%.*]] = add nsw i8 [[ZEXT_A]], [[SEXT_B]] ; CHECK-NEXT: call void @use(i8 [[ADD]]) ; CHECK-NEXT: [[R:%.*]] = icmp slt i8 [[ADD]], 1 ; CHECK-NEXT: ret i1 [[R]] ; %zext.a = zext i1 %a to i8 - %zext.b = sext i1 %b to i8 - %add = add i8 %zext.a, %zext.b + %sext.b = sext i1 %b to i8 + %add = add i8 %zext.a, %sext.b call void @use(i8 %add) %r = icmp slt i8 %add, 1 ret i1 %r @@ -795,14 +823,14 @@ define i1 @zext_sext_add_icmp_slt_1_no_oneuse(i1 %a, i1 %b) { define i1 @zext_sext_add_icmp_slt_1_rhs_not_const(i1 %a, i1 %b, i8 %c) { ; CHECK-LABEL: @zext_sext_add_icmp_slt_1_rhs_not_const( ; CHECK-NEXT: [[ZEXT_A:%.*]] = zext i1 [[A:%.*]] to i8 -; CHECK-NEXT: [[ZEXT_B:%.*]] = sext i1 [[B:%.*]] to i8 -; CHECK-NEXT: [[ADD:%.*]] = add nsw i8 [[ZEXT_A]], [[ZEXT_B]] +; CHECK-NEXT: [[SEXT_B:%.*]] = sext i1 [[B:%.*]] to i8 +; CHECK-NEXT: [[ADD:%.*]] = add nsw i8 [[ZEXT_A]], [[SEXT_B]] ; CHECK-NEXT: [[R:%.*]] = icmp slt i8 [[ADD]], [[C:%.*]] ; CHECK-NEXT: ret i1 [[R]] ; %zext.a = zext i1 %a to i8 - %zext.b = sext i1 %b to i8 - %add = add i8 %zext.a, %zext.b + %sext.b = sext i1 %b to i8 + %add = add i8 %zext.a, %sext.b %r = icmp slt i8 %add, %c ret i1 %r } @@ -810,14 +838,14 @@ define i1 @zext_sext_add_icmp_slt_1_rhs_not_const(i1 %a, i1 %b, i8 %c) { define i1 @zext_sext_add_icmp_slt_1_type_not_i1(i2 %a, i1 %b) { ; CHECK-LABEL: @zext_sext_add_icmp_slt_1_type_not_i1( ; CHECK-NEXT: [[ZEXT_A:%.*]] = zext i2 [[A:%.*]] to i8 -; CHECK-NEXT: [[ZEXT_B:%.*]] = sext i1 [[B:%.*]] to i8 -; CHECK-NEXT: [[ADD:%.*]] = add nsw i8 [[ZEXT_A]], [[ZEXT_B]] +; CHECK-NEXT: [[SEXT_B:%.*]] = sext i1 [[B:%.*]] to i8 +; CHECK-NEXT: [[ADD:%.*]] = add nsw i8 [[ZEXT_A]], [[SEXT_B]] ; CHECK-NEXT: [[R:%.*]] = icmp slt i8 [[ADD]], 1 ; CHECK-NEXT: ret i1 [[R]] ; %zext.a = zext i2 %a to i8 - %zext.b = sext i1 %b to i8 - %add = add i8 %zext.a, %zext.b + %sext.b = sext i1 %b to i8 + %add = add i8 %zext.a, %sext.b %r = icmp slt i8 %add, 1 ret i1 %r } -- 2.7.4