[PATCH] D154573: [InstCombine] Add tests for folding `(icmp eq/ne (zext i1) (sext i1))`; NFC
Noah Goldstein via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 6 00:30:44 PDT 2023
goldstein.w.n created this revision.
goldstein.w.n added reviewers: nikic, RKSimon.
Herald added a subscriber: StephenFan.
Herald added a project: All.
goldstein.w.n requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D154573
Files:
llvm/test/Transforms/InstCombine/icmp-ext-ext.ll
Index: llvm/test/Transforms/InstCombine/icmp-ext-ext.ll
===================================================================
--- llvm/test/Transforms/InstCombine/icmp-ext-ext.ll
+++ llvm/test/Transforms/InstCombine/icmp-ext-ext.ll
@@ -380,3 +380,43 @@
%c = icmp uge i32 %a, %b
ret i1 %c
}
+
+
+define i1 @zext_eq_sext(i1 %a, i1 %b) {
+; CHECK-LABEL: @zext_eq_sext(
+; CHECK-NEXT: [[CONV:%.*]] = zext i1 [[A:%.*]] to i32
+; CHECK-NEXT: [[CONV3_NEG:%.*]] = sext i1 [[B:%.*]] to i32
+; CHECK-NEXT: [[TOBOOL4:%.*]] = icmp eq i32 [[CONV]], [[CONV3_NEG]]
+; CHECK-NEXT: ret i1 [[TOBOOL4]]
+;
+ %conv = zext i1 %a to i32
+ %conv3.neg = sext i1 %b to i32
+ %tobool4 = icmp eq i32 %conv, %conv3.neg
+ ret i1 %tobool4
+}
+
+define i1 @zext_eq_sext_fail_not_i1(i1 %a, i8 %b) {
+; CHECK-LABEL: @zext_eq_sext_fail_not_i1(
+; CHECK-NEXT: [[CONV:%.*]] = zext i1 [[A:%.*]] to i32
+; CHECK-NEXT: [[CONV3_NEG:%.*]] = sext i8 [[B:%.*]] to i32
+; CHECK-NEXT: [[TOBOOL4:%.*]] = icmp eq i32 [[CONV]], [[CONV3_NEG]]
+; CHECK-NEXT: ret i1 [[TOBOOL4]]
+;
+ %conv = zext i1 %a to i32
+ %conv3.neg = sext i8 %b to i32
+ %tobool4 = icmp eq i32 %conv, %conv3.neg
+ ret i1 %tobool4
+}
+
+define <2 x i1> @zext_ne_sext(<2 x i1> %a, <2 x i1> %b) {
+; CHECK-LABEL: @zext_ne_sext(
+; CHECK-NEXT: [[CONV:%.*]] = zext <2 x i1> [[A:%.*]] to <2 x i8>
+; CHECK-NEXT: [[CONV3_NEG:%.*]] = sext <2 x i1> [[B:%.*]] to <2 x i8>
+; CHECK-NEXT: [[TOBOOL4:%.*]] = icmp ne <2 x i8> [[CONV3_NEG]], [[CONV]]
+; CHECK-NEXT: ret <2 x i1> [[TOBOOL4]]
+;
+ %conv = zext <2 x i1> %a to <2 x i8>
+ %conv3.neg = sext <2 x i1> %b to <2 x i8>
+ %tobool4 = icmp ne <2 x i8> %conv3.neg, %conv
+ ret <2 x i1> %tobool4
+}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D154573.537612.patch
Type: text/x-patch
Size: 1713 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230706/3730c547/attachment.bin>
More information about the llvm-commits
mailing list