[llvm] 3aec4f9 - [InstCombine] Add pre-commit tests for PR65845
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Sun Sep 17 04:23:52 PDT 2023
Author: Yingwei Zheng
Date: 2023-09-17T19:23:17+08:00
New Revision: 3aec4f9ae3b8dd3640e9fa29091b393c17861c03
URL: https://github.com/llvm/llvm-project/commit/3aec4f9ae3b8dd3640e9fa29091b393c17861c03
DIFF: https://github.com/llvm/llvm-project/commit/3aec4f9ae3b8dd3640e9fa29091b393c17861c03.diff
LOG: [InstCombine] Add pre-commit tests for PR65845
See also https://reviews.llvm.org/D158983
Added:
Modified:
llvm/test/Transforms/InstCombine/select-and-or.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/InstCombine/select-and-or.ll b/llvm/test/Transforms/InstCombine/select-and-or.ll
index fb78f0affcb8f14..ea4df8446768a30 100644
--- a/llvm/test/Transforms/InstCombine/select-and-or.ll
+++ b/llvm/test/Transforms/InstCombine/select-and-or.ll
@@ -477,32 +477,34 @@ define i1 @and_or2(i1 %a, i1 %b, i1 %c) {
ret i1 %r
}
-define i1 @and_or1_bundef(i1 %a, i1 noundef %b, i1 %c) {
-; CHECK-LABEL: @and_or1_bundef(
-; CHECK-NEXT: [[TMP1:%.*]] = or i1 [[C:%.*]], [[B:%.*]]
-; CHECK-NEXT: [[R:%.*]] = and i1 [[TMP1]], [[A:%.*]]
+define i1 @and_or1_commuted(i1 %a, i1 %b, i1 %c) {
+; CHECK-LABEL: @and_or1_commuted(
+; CHECK-NEXT: [[TMP1:%.*]] = freeze i1 [[B:%.*]]
+; CHECK-NEXT: [[TMP2:%.*]] = or i1 [[TMP1]], [[C:%.*]]
+; CHECK-NEXT: [[R:%.*]] = and i1 [[TMP2]], [[A:%.*]]
; CHECK-NEXT: ret i1 [[R]]
;
%nota = xor i1 %a, true
- %cond = or i1 %nota, %c
+ %cond = or i1 %c, %nota
%r = select i1 %cond, i1 %a, i1 %b
ret i1 %r
}
-define i1 @and_or2_aundef(i1 noundef %a, i1 %b, i1 %c) {
-; CHECK-LABEL: @and_or2_aundef(
-; CHECK-NEXT: [[TMP1:%.*]] = or i1 [[C:%.*]], [[A:%.*]]
-; CHECK-NEXT: [[R:%.*]] = and i1 [[TMP1]], [[B:%.*]]
+define i1 @and_or2_commuted(i1 %a, i1 %b, i1 %c) {
+; CHECK-LABEL: @and_or2_commuted(
+; CHECK-NEXT: [[TMP1:%.*]] = freeze i1 [[A:%.*]]
+; CHECK-NEXT: [[TMP2:%.*]] = or i1 [[TMP1]], [[C:%.*]]
+; CHECK-NEXT: [[R:%.*]] = and i1 [[TMP2]], [[B:%.*]]
; CHECK-NEXT: ret i1 [[R]]
;
%notc = xor i1 %c, true
- %cond = and i1 %notc, %b
+ %cond = and i1 %b, %notc
%r = select i1 %cond, i1 %a, i1 %b
ret i1 %r
}
-define i1 @no_and_or1_bundef(i1 %a, i1 noundef %b, i1 %c) {
-; CHECK-LABEL: @no_and_or1_bundef(
+define i1 @and_or1_multiuse(i1 %a, i1 %b, i1 %c) {
+; CHECK-LABEL: @and_or1_multiuse(
; CHECK-NEXT: [[NOTA:%.*]] = xor i1 [[A:%.*]], true
; CHECK-NEXT: [[COND:%.*]] = or i1 [[NOTA]], [[C:%.*]]
; CHECK-NEXT: call void @use(i1 [[COND]])
@@ -516,8 +518,8 @@ define i1 @no_and_or1_bundef(i1 %a, i1 noundef %b, i1 %c) {
ret i1 %r
}
-define i1 @no_and_or2_aundef(i1 noundef %a, i1 %b, i1 %c) {
-; CHECK-LABEL: @no_and_or2_aundef(
+define i1 @and_or2_multiuse(i1 %a, i1 %b, i1 %c) {
+; CHECK-LABEL: @and_or2_multiuse(
; CHECK-NEXT: [[NOTC:%.*]] = xor i1 [[C:%.*]], true
; CHECK-NEXT: [[COND:%.*]] = and i1 [[NOTC]], [[B:%.*]]
; CHECK-NEXT: call void @use(i1 [[COND]])
@@ -531,38 +533,68 @@ define i1 @no_and_or2_aundef(i1 noundef %a, i1 %b, i1 %c) {
ret i1 %r
}
-define i1 @and_or1_op1not(i1 %a, i1 %b) {
-; CHECK-LABEL: @and_or1_op1not(
-; CHECK-NEXT: [[C:%.*]] = call i1 @gen_i1()
-; CHECK-NEXT: [[TMP1:%.*]] = freeze i1 [[B:%.*]]
-; CHECK-NEXT: [[TMP2:%.*]] = or i1 [[C]], [[TMP1]]
-; CHECK-NEXT: [[R:%.*]] = and i1 [[TMP2]], [[A:%.*]]
-; CHECK-NEXT: ret i1 [[R]]
+define <2 x i1> @and_or1_vec(<2 x i1> %a, <2 x i1> %b) {
+; CHECK-LABEL: @and_or1_vec(
+; CHECK-NEXT: [[C:%.*]] = call <2 x i1> @gen_v2i1()
+; CHECK-NEXT: [[TMP1:%.*]] = freeze <2 x i1> [[B:%.*]]
+; CHECK-NEXT: [[TMP2:%.*]] = or <2 x i1> [[C]], [[TMP1]]
+; CHECK-NEXT: [[R:%.*]] = and <2 x i1> [[TMP2]], [[A:%.*]]
+; CHECK-NEXT: ret <2 x i1> [[R]]
;
- %c = call i1 @gen_i1()
- %nota = xor i1 %a, true
- %cond = or i1 %c, %nota
- %r = select i1 %cond, i1 %a, i1 %b
- ret i1 %r
+ %c = call <2 x i1> @gen_v2i1()
+ %nota = xor <2 x i1> %a, <i1 true, i1 true>
+ %cond = or <2 x i1> %nota, %c
+ %r = select <2 x i1> %cond, <2 x i1> %a, <2 x i1> %b
+ ret <2 x i1> %r
}
-define i1 @and_or2_op1not(i1 %a, i1 %c) {
-; CHECK-LABEL: @and_or2_op1not(
-; CHECK-NEXT: [[B:%.*]] = call i1 @gen_i1()
-; CHECK-NEXT: [[TMP1:%.*]] = freeze i1 [[A:%.*]]
-; CHECK-NEXT: [[TMP2:%.*]] = or i1 [[TMP1]], [[C:%.*]]
-; CHECK-NEXT: [[R:%.*]] = and i1 [[B]], [[TMP2]]
-; CHECK-NEXT: ret i1 [[R]]
+define <2 x i1> @and_or2_vec(<2 x i1> %a, <2 x i1> %b) {
+; CHECK-LABEL: @and_or2_vec(
+; CHECK-NEXT: [[C:%.*]] = call <2 x i1> @gen_v2i1()
+; CHECK-NEXT: [[TMP1:%.*]] = freeze <2 x i1> [[A:%.*]]
+; CHECK-NEXT: [[TMP2:%.*]] = or <2 x i1> [[C]], [[TMP1]]
+; CHECK-NEXT: [[R:%.*]] = and <2 x i1> [[TMP2]], [[B:%.*]]
+; CHECK-NEXT: ret <2 x i1> [[R]]
;
- %b = call i1 @gen_i1()
- %notc = xor i1 %c, true
- %cond = and i1 %b, %notc
- %r = select i1 %cond, i1 %a, i1 %b
- ret i1 %r
+ %c = call <2 x i1> @gen_v2i1()
+ %notc = xor <2 x i1> %c, <i1 true, i1 true>
+ %cond = and <2 x i1> %notc, %b
+ %r = select <2 x i1> %cond, <2 x i1> %a, <2 x i1> %b
+ ret <2 x i1> %r
}
-define i1 @neg_and_or1(i1 %a, i1 %b, i1 %c, i1 %d) {
-; CHECK-LABEL: @neg_and_or1(
+define <2 x i1> @and_or1_vec_commuted(<2 x i1> %a, <2 x i1> %b) {
+; CHECK-LABEL: @and_or1_vec_commuted(
+; CHECK-NEXT: [[C:%.*]] = call <2 x i1> @gen_v2i1()
+; CHECK-NEXT: [[TMP1:%.*]] = freeze <2 x i1> [[B:%.*]]
+; CHECK-NEXT: [[TMP2:%.*]] = or <2 x i1> [[C]], [[TMP1]]
+; CHECK-NEXT: [[R:%.*]] = and <2 x i1> [[TMP2]], [[A:%.*]]
+; CHECK-NEXT: ret <2 x i1> [[R]]
+;
+ %c = call <2 x i1> @gen_v2i1()
+ %nota = xor <2 x i1> %a, <i1 true, i1 true>
+ %cond = or <2 x i1> %c, %nota
+ %r = select <2 x i1> %cond, <2 x i1> %a, <2 x i1> %b
+ ret <2 x i1> %r
+}
+
+define <2 x i1> @and_or2_vec_commuted(<2 x i1> %a, <2 x i1> %b) {
+; CHECK-LABEL: @and_or2_vec_commuted(
+; CHECK-NEXT: [[C:%.*]] = call <2 x i1> @gen_v2i1()
+; CHECK-NEXT: [[TMP1:%.*]] = freeze <2 x i1> [[A:%.*]]
+; CHECK-NEXT: [[TMP2:%.*]] = or <2 x i1> [[C]], [[TMP1]]
+; CHECK-NEXT: [[R:%.*]] = and <2 x i1> [[TMP2]], [[B:%.*]]
+; CHECK-NEXT: ret <2 x i1> [[R]]
+;
+ %c = call <2 x i1> @gen_v2i1()
+ %notc = xor <2 x i1> %c, <i1 true, i1 true>
+ %cond = and <2 x i1> %b, %notc
+ %r = select <2 x i1> %cond, <2 x i1> %a, <2 x i1> %b
+ ret <2 x i1> %r
+}
+
+define i1 @and_or1_wrong_operand(i1 %a, i1 %b, i1 %c, i1 %d) {
+; CHECK-LABEL: @and_or1_wrong_operand(
; CHECK-NEXT: [[NOTA:%.*]] = xor i1 [[A:%.*]], true
; CHECK-NEXT: [[COND:%.*]] = or i1 [[NOTA]], [[C:%.*]]
; CHECK-NEXT: [[R:%.*]] = select i1 [[COND]], i1 [[D:%.*]], i1 [[B:%.*]]
@@ -574,8 +606,8 @@ define i1 @neg_and_or1(i1 %a, i1 %b, i1 %c, i1 %d) {
ret i1 %r
}
-define i1 @neg_and_or2(i1 %a, i1 %b, i1 %c, i1 %d) {
-; CHECK-LABEL: @neg_and_or2(
+define i1 @and_or2_wrong_operand(i1 %a, i1 %b, i1 %c, i1 %d) {
+; CHECK-LABEL: @and_or2_wrong_operand(
; CHECK-NEXT: [[NOTC:%.*]] = xor i1 [[C:%.*]], true
; CHECK-NEXT: [[COND:%.*]] = and i1 [[NOTC]], [[B:%.*]]
; CHECK-NEXT: [[R:%.*]] = select i1 [[COND]], i1 [[A:%.*]], i1 [[D:%.*]]
@@ -587,21 +619,97 @@ define i1 @neg_and_or2(i1 %a, i1 %b, i1 %c, i1 %d) {
ret i1 %r
}
-define <2 x i1> @and_or1_op1not_vec(<2 x i1> %a, <2 x i1> %b) {
-; CHECK-LABEL: @and_or1_op1not_vec(
-; CHECK-NEXT: [[C:%.*]] = call <2 x i1> @gen_v2i1()
-; CHECK-NEXT: [[TMP1:%.*]] = freeze <2 x i1> [[B:%.*]]
-; CHECK-NEXT: [[TMP2:%.*]] = or <2 x i1> [[C]], [[TMP1]]
-; CHECK-NEXT: [[R:%.*]] = and <2 x i1> [[TMP2]], [[A:%.*]]
+define i1 @and_or3(i1 %a, i1 %b, i32 %x, i32 %y) {
+; CHECK-LABEL: @and_or3(
+; CHECK-NEXT: [[C:%.*]] = icmp eq i32 [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT: [[COND:%.*]] = and i1 [[C]], [[B:%.*]]
+; CHECK-NEXT: [[R:%.*]] = select i1 [[COND]], i1 [[A:%.*]], i1 [[B]]
+; CHECK-NEXT: ret i1 [[R]]
+;
+ %c = icmp eq i32 %x, %y
+ %cond = and i1 %b, %c
+ %r = select i1 %cond, i1 %a, i1 %b
+ ret i1 %r
+}
+
+define i1 @and_or3_commuted(i1 %a, i1 %b, i32 %x, i32 %y) {
+; CHECK-LABEL: @and_or3_commuted(
+; CHECK-NEXT: [[C:%.*]] = icmp eq i32 [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT: [[COND:%.*]] = and i1 [[C]], [[B:%.*]]
+; CHECK-NEXT: [[R:%.*]] = select i1 [[COND]], i1 [[A:%.*]], i1 [[B]]
+; CHECK-NEXT: ret i1 [[R]]
+;
+ %c = icmp eq i32 %x, %y
+ %cond = and i1 %c, %b
+ %r = select i1 %cond, i1 %a, i1 %b
+ ret i1 %r
+}
+
+define i1 @and_or3_not_free_to_invert(i1 %a, i1 %b, i1 %c) {
+; CHECK-LABEL: @and_or3_not_free_to_invert(
+; CHECK-NEXT: [[COND:%.*]] = and i1 [[B:%.*]], [[C:%.*]]
+; CHECK-NEXT: [[R:%.*]] = select i1 [[COND]], i1 [[A:%.*]], i1 [[B]]
+; CHECK-NEXT: ret i1 [[R]]
+;
+ %cond = and i1 %b, %c
+ %r = select i1 %cond, i1 %a, i1 %b
+ ret i1 %r
+}
+
+define i1 @and_or3_multiuse(i1 %a, i1 %b, i32 %x, i32 %y) {
+; CHECK-LABEL: @and_or3_multiuse(
+; CHECK-NEXT: [[C:%.*]] = icmp eq i32 [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT: [[COND:%.*]] = and i1 [[C]], [[B:%.*]]
+; CHECK-NEXT: call void @use(i1 [[COND]])
+; CHECK-NEXT: [[R:%.*]] = select i1 [[COND]], i1 [[A:%.*]], i1 [[B]]
+; CHECK-NEXT: ret i1 [[R]]
+;
+ %c = icmp eq i32 %x, %y
+ %cond = and i1 %b, %c
+ call void @use(i1 %cond)
+ %r = select i1 %cond, i1 %a, i1 %b
+ ret i1 %r
+}
+
+define <2 x i1> @and_or3_vec(<2 x i1> %a, <2 x i1> %b, <2 x i32> %x, <2 x i32> %y) {
+; CHECK-LABEL: @and_or3_vec(
+; CHECK-NEXT: [[C:%.*]] = icmp eq <2 x i32> [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT: [[COND:%.*]] = and <2 x i1> [[C]], [[B:%.*]]
+; CHECK-NEXT: [[R:%.*]] = select <2 x i1> [[COND]], <2 x i1> [[A:%.*]], <2 x i1> [[B]]
; CHECK-NEXT: ret <2 x i1> [[R]]
;
- %c = call <2 x i1> @gen_v2i1()
- %nota = xor <2 x i1> %a, <i1 true, i1 true>
- %cond = or <2 x i1> %c, %nota
+ %c = icmp eq <2 x i32> %x, %y
+ %cond = and <2 x i1> %b, %c
+ %r = select <2 x i1> %cond, <2 x i1> %a, <2 x i1> %b
+ ret <2 x i1> %r
+}
+
+define <2 x i1> @and_or3_vec_commuted(<2 x i1> %a, <2 x i1> %b, <2 x i32> %x, <2 x i32> %y) {
+; CHECK-LABEL: @and_or3_vec_commuted(
+; CHECK-NEXT: [[C:%.*]] = icmp eq <2 x i32> [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT: [[COND:%.*]] = and <2 x i1> [[C]], [[B:%.*]]
+; CHECK-NEXT: [[R:%.*]] = select <2 x i1> [[COND]], <2 x i1> [[A:%.*]], <2 x i1> [[B]]
+; CHECK-NEXT: ret <2 x i1> [[R]]
+;
+ %c = icmp eq <2 x i32> %x, %y
+ %cond = and <2 x i1> %c, %b
%r = select <2 x i1> %cond, <2 x i1> %a, <2 x i1> %b
ret <2 x i1> %r
}
+define i1 @and_or3_wrong_operand(i1 %a, i1 %b, i32 %x, i32 %y, i1 %d) {
+; CHECK-LABEL: @and_or3_wrong_operand(
+; CHECK-NEXT: [[C:%.*]] = icmp eq i32 [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT: [[COND:%.*]] = and i1 [[C]], [[B:%.*]]
+; CHECK-NEXT: [[R:%.*]] = select i1 [[COND]], i1 [[A:%.*]], i1 [[D:%.*]]
+; CHECK-NEXT: ret i1 [[R]]
+;
+ %c = icmp eq i32 %x, %y
+ %cond = and i1 %b, %c
+ %r = select i1 %cond, i1 %a, i1 %d
+ ret i1 %r
+}
+
define i1 @or_and1(i1 %a, i1 %b, i1 %c) {
; CHECK-LABEL: @or_and1(
; CHECK-NEXT: [[TMP1:%.*]] = select i1 [[C:%.*]], i1 [[A:%.*]], i1 false
More information about the llvm-commits
mailing list