[llvm] bba25c4 - [InstCombine] Precommit test for D134142
Markus Böck via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 20 06:11:05 PDT 2022
Author: Markus Böck
Date: 2022-09-20T15:10:52+02:00
New Revision: bba25c4c9f13337413e3adde89397413c50a26a2
URL: https://github.com/llvm/llvm-project/commit/bba25c4c9f13337413e3adde89397413c50a26a2
DIFF: https://github.com/llvm/llvm-project/commit/bba25c4c9f13337413e3adde89397413c50a26a2.diff
LOG: [InstCombine] Precommit test for D134142
Added:
Modified:
llvm/test/Transforms/InstCombine/select.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/InstCombine/select.ll b/llvm/test/Transforms/InstCombine/select.ll
index f72e586a302f..0558138b8491 100644
--- a/llvm/test/Transforms/InstCombine/select.ll
+++ b/llvm/test/Transforms/InstCombine/select.ll
@@ -3210,3 +3210,163 @@ declare void @use(i1)
declare void @use_i8(i8)
declare void @use_i32(i32)
declare i32 @llvm.cttz.i32(i32, i1 immarg)
+
+define i32 @select_cond_zext_cond(i1 %cond, i32 %b) {
+; CHECK-LABEL: @select_cond_zext_cond(
+; CHECK-NEXT: [[ZEXT:%.*]] = zext i1 [[COND:%.*]] to i32
+; CHECK-NEXT: [[SEL:%.*]] = select i1 [[COND]], i32 [[ZEXT]], i32 [[B:%.*]]
+; CHECK-NEXT: ret i32 [[SEL]]
+;
+ %zext = zext i1 %cond to i32
+ %sel = select i1 %cond, i32 %zext, i32 %b
+ ret i32 %sel
+}
+
+define <2 x i32> @select_cond_zext_cond_vec(<2 x i1> %cond, <2 x i32> %b) {
+; CHECK-LABEL: @select_cond_zext_cond_vec(
+; CHECK-NEXT: [[ZEXT:%.*]] = zext <2 x i1> [[COND:%.*]] to <2 x i32>
+; CHECK-NEXT: [[SEL:%.*]] = select <2 x i1> [[COND]], <2 x i32> [[ZEXT]], <2 x i32> [[B:%.*]]
+; CHECK-NEXT: ret <2 x i32> [[SEL]]
+;
+ %zext = zext <2 x i1> %cond to <2 x i32>
+ %sel = select <2 x i1> %cond, <2 x i32> %zext, <2 x i32> %b
+ ret <2 x i32> %sel
+}
+
+define i32 @select_cond_sext_cond(i1 %cond, i32 %b) {
+; CHECK-LABEL: @select_cond_sext_cond(
+; CHECK-NEXT: [[SEXT:%.*]] = sext i1 [[COND:%.*]] to i32
+; CHECK-NEXT: [[SEL:%.*]] = select i1 [[COND]], i32 [[SEXT]], i32 [[B:%.*]]
+; CHECK-NEXT: ret i32 [[SEL]]
+;
+ %sext = sext i1 %cond to i32
+ %sel = select i1 %cond, i32 %sext, i32 %b
+ ret i32 %sel
+}
+
+define <2 x i32> @select_cond_sext_cond_vec(<2 x i1> %cond, <2 x i32> %b) {
+; CHECK-LABEL: @select_cond_sext_cond_vec(
+; CHECK-NEXT: [[SEXT:%.*]] = sext <2 x i1> [[COND:%.*]] to <2 x i32>
+; CHECK-NEXT: [[SEL:%.*]] = select <2 x i1> [[COND]], <2 x i32> [[SEXT]], <2 x i32> [[B:%.*]]
+; CHECK-NEXT: ret <2 x i32> [[SEL]]
+;
+ %sext = sext <2 x i1> %cond to <2 x i32>
+ %sel = select <2 x i1> %cond, <2 x i32> %sext, <2 x i32> %b
+ ret <2 x i32> %sel
+}
+
+define i32 @select_cond_val_zext_cond(i1 %cond, i32 %b) {
+; CHECK-LABEL: @select_cond_val_zext_cond(
+; CHECK-NEXT: [[ZEXT:%.*]] = zext i1 [[COND:%.*]] to i32
+; CHECK-NEXT: [[SEL:%.*]] = select i1 [[COND]], i32 [[B:%.*]], i32 [[ZEXT]]
+; CHECK-NEXT: ret i32 [[SEL]]
+;
+ %zext = zext i1 %cond to i32
+ %sel = select i1 %cond, i32 %b, i32 %zext
+ ret i32 %sel
+}
+
+define <2 x i32> @select_cond_val_zext_cond_vec(<2 x i1> %cond, <2 x i32> %b) {
+; CHECK-LABEL: @select_cond_val_zext_cond_vec(
+; CHECK-NEXT: [[ZEXT:%.*]] = zext <2 x i1> [[COND:%.*]] to <2 x i32>
+; CHECK-NEXT: [[SEL:%.*]] = select <2 x i1> [[COND]], <2 x i32> [[B:%.*]], <2 x i32> [[ZEXT]]
+; CHECK-NEXT: ret <2 x i32> [[SEL]]
+;
+ %zext = zext <2 x i1> %cond to <2 x i32>
+ %sel = select <2 x i1> %cond, <2 x i32> %b, <2 x i32> %zext
+ ret <2 x i32> %sel
+}
+
+define i32 @select_cond_val_sext_cond(i1 %cond, i32 %b) {
+; CHECK-LABEL: @select_cond_val_sext_cond(
+; CHECK-NEXT: [[SEXT:%.*]] = sext i1 [[COND:%.*]] to i32
+; CHECK-NEXT: [[SEL:%.*]] = select i1 [[COND]], i32 [[B:%.*]], i32 [[SEXT]]
+; CHECK-NEXT: ret i32 [[SEL]]
+;
+ %sext = sext i1 %cond to i32
+ %sel = select i1 %cond, i32 %b, i32 %sext
+ ret i32 %sel
+}
+
+define i32 @select_cond_zext_not_cond_val(i1 %cond, i32 %b) {
+; CHECK-LABEL: @select_cond_zext_not_cond_val(
+; CHECK-NEXT: [[NOT_COND:%.*]] = xor i1 [[COND:%.*]], true
+; CHECK-NEXT: [[ZEXT:%.*]] = zext i1 [[NOT_COND]] to i32
+; CHECK-NEXT: [[SEL:%.*]] = select i1 [[COND]], i32 [[ZEXT]], i32 [[B:%.*]]
+; CHECK-NEXT: ret i32 [[SEL]]
+;
+ %not_cond = xor i1 %cond, true
+ %zext = zext i1 %not_cond to i32
+ %sel = select i1 %cond, i32 %zext, i32 %b
+ ret i32 %sel
+}
+
+define i32 @select_cond_sext_not_cond_val(i1 %cond, i32 %b) {
+; CHECK-LABEL: @select_cond_sext_not_cond_val(
+; CHECK-NEXT: [[NOT_COND:%.*]] = xor i1 [[COND:%.*]], true
+; CHECK-NEXT: [[SEXT:%.*]] = sext i1 [[NOT_COND]] to i32
+; CHECK-NEXT: [[SEL:%.*]] = select i1 [[COND]], i32 [[SEXT]], i32 [[B:%.*]]
+; CHECK-NEXT: ret i32 [[SEL]]
+;
+ %not_cond = xor i1 %cond, true
+ %sext = sext i1 %not_cond to i32
+ %sel = select i1 %cond, i32 %sext, i32 %b
+ ret i32 %sel
+}
+
+
+define i32 @select_cond_val_zext_not_cond(i1 %cond, i32 %b) {
+; CHECK-LABEL: @select_cond_val_zext_not_cond(
+; CHECK-NEXT: [[NOT_COND:%.*]] = xor i1 [[COND:%.*]], true
+; CHECK-NEXT: [[ZEXT:%.*]] = zext i1 [[NOT_COND]] to i32
+; CHECK-NEXT: [[SEL:%.*]] = select i1 [[COND]], i32 [[B:%.*]], i32 [[ZEXT]]
+; CHECK-NEXT: ret i32 [[SEL]]
+;
+ %not_cond = xor i1 %cond, true
+ %zext = zext i1 %not_cond to i32
+ %sel = select i1 %cond, i32 %b, i32 %zext
+ ret i32 %sel
+}
+
+define i32 @select_cond_val_sext_not_cond(i1 %cond, i32 %b) {
+; CHECK-LABEL: @select_cond_val_sext_not_cond(
+; CHECK-NEXT: [[NOT_COND:%.*]] = xor i1 [[COND:%.*]], true
+; CHECK-NEXT: [[SEXT:%.*]] = sext i1 [[NOT_COND]] to i32
+; CHECK-NEXT: [[SEL:%.*]] = select i1 [[COND]], i32 [[B:%.*]], i32 [[SEXT]]
+; CHECK-NEXT: ret i32 [[SEL]]
+;
+ %not_cond = xor i1 %cond, true
+ %sext = sext i1 %not_cond to i32
+ %sel = select i1 %cond, i32 %b, i32 %sext
+ ret i32 %sel
+}
+
+define i32 @select_cond_not_cond_cond1(i1 %cond) {
+; CHECK-LABEL: @select_cond_not_cond_cond1(
+; CHECK-NEXT: [[Z:%.*]] = zext i1 [[COND:%.*]] to i32
+; CHECK-NEXT: [[NOT_COND:%.*]] = xor i1 [[COND]], true
+; CHECK-NEXT: [[S:%.*]] = sext i1 [[NOT_COND]] to i32
+; CHECK-NEXT: [[V:%.*]] = select i1 [[COND]], i32 [[S]], i32 [[Z]]
+; CHECK-NEXT: ret i32 [[V]]
+;
+ %z = zext i1 %cond to i32
+ %not_cond = xor i1 %cond, true
+ %s = sext i1 %not_cond to i32
+ %v = select i1 %cond, i32 %s, i32 %z
+ ret i32 %v
+}
+
+define i32 @select_cond_not_cond_cond2(i1 %cond) {
+; CHECK-LABEL: @select_cond_not_cond_cond2(
+; CHECK-NEXT: [[Z:%.*]] = sext i1 [[COND:%.*]] to i32
+; CHECK-NEXT: [[NOT_COND:%.*]] = xor i1 [[COND]], true
+; CHECK-NEXT: [[S:%.*]] = zext i1 [[NOT_COND]] to i32
+; CHECK-NEXT: [[V:%.*]] = select i1 [[COND]], i32 [[S]], i32 [[Z]]
+; CHECK-NEXT: ret i32 [[V]]
+;
+ %z = sext i1 %cond to i32
+ %not_cond = xor i1 %cond, true
+ %s = zext i1 %not_cond to i32
+ %v = select i1 %cond, i32 %s, i32 %z
+ ret i32 %v
+}
More information about the llvm-commits
mailing list