[llvm] d10ee89 - [InstCombine] Add `sext` version of pre-commit tests for PR65852. NFC.
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 18 10:53:46 PDT 2023
Author: Yingwei Zheng
Date: 2023-09-19T01:53:22+08:00
New Revision: d10ee8942f7ea716d6cfbac279bfd6562f6237a2
URL: https://github.com/llvm/llvm-project/commit/d10ee8942f7ea716d6cfbac279bfd6562f6237a2
DIFF: https://github.com/llvm/llvm-project/commit/d10ee8942f7ea716d6cfbac279bfd6562f6237a2.diff
LOG: [InstCombine] Add `sext` version of pre-commit tests for PR65852. NFC.
Added:
Modified:
llvm/test/Transforms/InstCombine/icmp-range.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/InstCombine/icmp-range.ll b/llvm/test/Transforms/InstCombine/icmp-range.ll
index a26e760059b43fe..3271c5590a9d1ce 100644
--- a/llvm/test/Transforms/InstCombine/icmp-range.ll
+++ b/llvm/test/Transforms/InstCombine/icmp-range.ll
@@ -1256,6 +1256,227 @@ define <2 x i1> @icmp_ne_zext_eq_non_boolean_vec(<2 x i32> %a) {
ret <2 x i1> %cmp1
}
+define i1 @icmp_ne_sext_eq_zero(i32 %a) {
+; CHECK-LABEL: @icmp_ne_sext_eq_zero(
+; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[A:%.*]], 0
+; CHECK-NEXT: [[CONV:%.*]] = sext i1 [[CMP]] to i32
+; CHECK-NEXT: [[CMP1:%.*]] = icmp ne i32 [[CONV]], [[A]]
+; CHECK-NEXT: ret i1 [[CMP1]]
+;
+ %cmp = icmp eq i32 %a, 0
+ %conv = sext i1 %cmp to i32
+ %cmp1 = icmp ne i32 %conv, %a
+ ret i1 %cmp1
+}
+
+define i1 @icmp_ne_sext_ne_zero(i32 %a) {
+; CHECK-LABEL: @icmp_ne_sext_ne_zero(
+; CHECK-NEXT: [[CMP:%.*]] = icmp ne i32 [[A:%.*]], 0
+; CHECK-NEXT: [[CONV:%.*]] = sext i1 [[CMP]] to i32
+; CHECK-NEXT: [[CMP1:%.*]] = icmp ne i32 [[CONV]], [[A]]
+; CHECK-NEXT: ret i1 [[CMP1]]
+;
+ %cmp = icmp ne i32 %a, 0
+ %conv = sext i1 %cmp to i32
+ %cmp1 = icmp ne i32 %conv, %a
+ ret i1 %cmp1
+}
+
+define i1 @icmp_eq_sext_eq_zero(i32 %a) {
+; CHECK-LABEL: @icmp_eq_sext_eq_zero(
+; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[A:%.*]], 0
+; CHECK-NEXT: [[CONV:%.*]] = sext i1 [[CMP]] to i32
+; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i32 [[CONV]], [[A]]
+; CHECK-NEXT: ret i1 [[CMP1]]
+;
+ %cmp = icmp eq i32 %a, 0
+ %conv = sext i1 %cmp to i32
+ %cmp1 = icmp eq i32 %conv, %a
+ ret i1 %cmp1
+}
+
+define i1 @icmp_eq_sext_ne_zero(i32 %a) {
+; CHECK-LABEL: @icmp_eq_sext_ne_zero(
+; CHECK-NEXT: [[CMP:%.*]] = icmp ne i32 [[A:%.*]], 0
+; CHECK-NEXT: [[CONV:%.*]] = sext i1 [[CMP]] to i32
+; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i32 [[CONV]], [[A]]
+; CHECK-NEXT: ret i1 [[CMP1]]
+;
+ %cmp = icmp ne i32 %a, 0
+ %conv = sext i1 %cmp to i32
+ %cmp1 = icmp eq i32 %conv, %a
+ ret i1 %cmp1
+}
+
+define i1 @icmp_ne_sext_eq_allone(i32 %a) {
+; CHECK-LABEL: @icmp_ne_sext_eq_allone(
+; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[A:%.*]], -1
+; CHECK-NEXT: [[CONV:%.*]] = sext i1 [[CMP]] to i32
+; CHECK-NEXT: [[CMP1:%.*]] = icmp ne i32 [[CONV]], [[A]]
+; CHECK-NEXT: ret i1 [[CMP1]]
+;
+ %cmp = icmp eq i32 %a, -1
+ %conv = sext i1 %cmp to i32
+ %cmp1 = icmp ne i32 %conv, %a
+ ret i1 %cmp1
+}
+
+define i1 @icmp_ne_sext_ne_allone(i32 %a) {
+; CHECK-LABEL: @icmp_ne_sext_ne_allone(
+; CHECK-NEXT: [[CMP:%.*]] = icmp ne i32 [[A:%.*]], -1
+; CHECK-NEXT: [[CONV:%.*]] = sext i1 [[CMP]] to i32
+; CHECK-NEXT: [[CMP1:%.*]] = icmp ne i32 [[CONV]], [[A]]
+; CHECK-NEXT: ret i1 [[CMP1]]
+;
+ %cmp = icmp ne i32 %a, -1
+ %conv = sext i1 %cmp to i32
+ %cmp1 = icmp ne i32 %conv, %a
+ ret i1 %cmp1
+}
+
+define i1 @icmp_eq_sext_eq_allone(i32 %a) {
+; CHECK-LABEL: @icmp_eq_sext_eq_allone(
+; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[A:%.*]], -1
+; CHECK-NEXT: [[CONV:%.*]] = sext i1 [[CMP]] to i32
+; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i32 [[CONV]], [[A]]
+; CHECK-NEXT: ret i1 [[CMP1]]
+;
+ %cmp = icmp eq i32 %a, -1
+ %conv = sext i1 %cmp to i32
+ %cmp1 = icmp eq i32 %conv, %a
+ ret i1 %cmp1
+}
+
+define i1 @icmp_eq_sext_ne_allone(i32 %a) {
+; CHECK-LABEL: @icmp_eq_sext_ne_allone(
+; CHECK-NEXT: [[CMP:%.*]] = icmp ne i32 [[A:%.*]], -1
+; CHECK-NEXT: [[CONV:%.*]] = sext i1 [[CMP]] to i32
+; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i32 [[CONV]], [[A]]
+; CHECK-NEXT: ret i1 [[CMP1]]
+;
+ %cmp = icmp ne i32 %a, -1
+ %conv = sext i1 %cmp to i32
+ %cmp1 = icmp eq i32 %conv, %a
+ ret i1 %cmp1
+}
+
+define i1 @icmp_ne_sext_eq_otherwise(i32 %a) {
+; CHECK-LABEL: @icmp_ne_sext_eq_otherwise(
+; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[A:%.*]], 2
+; CHECK-NEXT: [[CONV:%.*]] = sext i1 [[CMP]] to i32
+; CHECK-NEXT: [[CMP1:%.*]] = icmp ne i32 [[CONV]], [[A]]
+; CHECK-NEXT: ret i1 [[CMP1]]
+;
+ %cmp = icmp eq i32 %a, 2
+ %conv = sext i1 %cmp to i32
+ %cmp1 = icmp ne i32 %conv, %a
+ ret i1 %cmp1
+}
+
+define i1 @icmp_ne_sext_ne_otherwise(i32 %a) {
+; CHECK-LABEL: @icmp_ne_sext_ne_otherwise(
+; CHECK-NEXT: [[CMP:%.*]] = icmp ne i32 [[A:%.*]], 2
+; CHECK-NEXT: [[CONV:%.*]] = sext i1 [[CMP]] to i32
+; CHECK-NEXT: [[CMP1:%.*]] = icmp ne i32 [[CONV]], [[A]]
+; CHECK-NEXT: ret i1 [[CMP1]]
+;
+ %cmp = icmp ne i32 %a, 2
+ %conv = sext i1 %cmp to i32
+ %cmp1 = icmp ne i32 %conv, %a
+ ret i1 %cmp1
+}
+
+define i1 @icmp_eq_sext_eq_otherwise(i32 %a) {
+; CHECK-LABEL: @icmp_eq_sext_eq_otherwise(
+; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[A:%.*]], 2
+; CHECK-NEXT: [[CONV:%.*]] = sext i1 [[CMP]] to i32
+; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i32 [[CONV]], [[A]]
+; CHECK-NEXT: ret i1 [[CMP1]]
+;
+ %cmp = icmp eq i32 %a, 2
+ %conv = sext i1 %cmp to i32
+ %cmp1 = icmp eq i32 %conv, %a
+ ret i1 %cmp1
+}
+
+define i1 @icmp_eq_sext_ne_otherwise(i32 %a) {
+; CHECK-LABEL: @icmp_eq_sext_ne_otherwise(
+; CHECK-NEXT: [[CMP:%.*]] = icmp ne i32 [[A:%.*]], 2
+; CHECK-NEXT: [[CONV:%.*]] = sext i1 [[CMP]] to i32
+; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i32 [[CONV]], [[A]]
+; CHECK-NEXT: ret i1 [[CMP1]]
+;
+ %cmp = icmp ne i32 %a, 2
+ %conv = sext i1 %cmp to i32
+ %cmp1 = icmp eq i32 %conv, %a
+ ret i1 %cmp1
+}
+
+define <2 x i1> @icmp_ne_sext_eq_zero_vec(<2 x i32> %a) {
+; CHECK-LABEL: @icmp_ne_sext_eq_zero_vec(
+; CHECK-NEXT: [[CMP:%.*]] = icmp eq <2 x i32> [[A:%.*]], zeroinitializer
+; CHECK-NEXT: [[CONV:%.*]] = sext <2 x i1> [[CMP]] to <2 x i32>
+; CHECK-NEXT: [[CMP1:%.*]] = icmp ne <2 x i32> [[CONV]], [[A]]
+; CHECK-NEXT: ret <2 x i1> [[CMP1]]
+;
+ %cmp = icmp eq <2 x i32> %a, <i32 0, i32 0>
+ %conv = sext <2 x i1> %cmp to <2 x i32>
+ %cmp1 = icmp ne <2 x i32> %conv, %a
+ ret <2 x i1> %cmp1
+}
+
+define <2 x i1> @icmp_ne_sext_ne_zero_vec(<2 x i32> %a) {
+; CHECK-LABEL: @icmp_ne_sext_ne_zero_vec(
+; CHECK-NEXT: [[CMP:%.*]] = icmp ne <2 x i32> [[A:%.*]], zeroinitializer
+; CHECK-NEXT: [[CONV:%.*]] = sext <2 x i1> [[CMP]] to <2 x i32>
+; CHECK-NEXT: [[CMP1:%.*]] = icmp ne <2 x i32> [[CONV]], [[A]]
+; CHECK-NEXT: ret <2 x i1> [[CMP1]]
+;
+ %cmp = icmp ne <2 x i32> %a, <i32 0, i32 0>
+ %conv = sext <2 x i1> %cmp to <2 x i32>
+ %cmp1 = icmp ne <2 x i32> %conv, %a
+ ret <2 x i1> %cmp1
+}
+
+define <2 x i1> @icmp_ne_sext_eq_allone_vec(<2 x i32> %a) {
+; CHECK-LABEL: @icmp_ne_sext_eq_allone_vec(
+; CHECK-NEXT: [[CMP:%.*]] = icmp eq <2 x i32> [[A:%.*]], <i32 -1, i32 -1>
+; CHECK-NEXT: [[CONV:%.*]] = sext <2 x i1> [[CMP]] to <2 x i32>
+; CHECK-NEXT: [[CMP1:%.*]] = icmp ne <2 x i32> [[CONV]], [[A]]
+; CHECK-NEXT: ret <2 x i1> [[CMP1]]
+;
+ %cmp = icmp eq <2 x i32> %a, <i32 -1, i32 -1>
+ %conv = sext <2 x i1> %cmp to <2 x i32>
+ %cmp1 = icmp ne <2 x i32> %conv, %a
+ ret <2 x i1> %cmp1
+}
+
+define <2 x i1> @icmp_ne_sext_ne_allone_vec(<2 x i32> %a) {
+; CHECK-LABEL: @icmp_ne_sext_ne_allone_vec(
+; CHECK-NEXT: [[CMP:%.*]] = icmp ne <2 x i32> [[A:%.*]], <i32 -1, i32 -1>
+; CHECK-NEXT: [[CONV:%.*]] = sext <2 x i1> [[CMP]] to <2 x i32>
+; CHECK-NEXT: [[CMP1:%.*]] = icmp ne <2 x i32> [[CONV]], [[A]]
+; CHECK-NEXT: ret <2 x i1> [[CMP1]]
+;
+ %cmp = icmp ne <2 x i32> %a, <i32 -1, i32 -1>
+ %conv = sext <2 x i1> %cmp to <2 x i32>
+ %cmp1 = icmp ne <2 x i32> %conv, %a
+ ret <2 x i1> %cmp1
+}
+
+define <2 x i1> @icmp_ne_sext_eq_otherwise_vec(<2 x i32> %a) {
+; CHECK-LABEL: @icmp_ne_sext_eq_otherwise_vec(
+; CHECK-NEXT: [[CMP:%.*]] = icmp eq <2 x i32> [[A:%.*]], <i32 2, i32 2>
+; CHECK-NEXT: [[CONV:%.*]] = sext <2 x i1> [[CMP]] to <2 x i32>
+; CHECK-NEXT: [[CMP1:%.*]] = icmp ne <2 x i32> [[CONV]], [[A]]
+; CHECK-NEXT: ret <2 x i1> [[CMP1]]
+;
+ %cmp = icmp eq <2 x i32> %a, <i32 2, i32 2>
+ %conv = sext <2 x i1> %cmp to <2 x i32>
+ %cmp1 = icmp ne <2 x i32> %conv, %a
+ ret <2 x i1> %cmp1
+}
+
!0 = !{i32 1, i32 6}
!1 = !{i32 0, i32 6}
!2 = !{i8 0, i8 1}
More information about the llvm-commits
mailing list