[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
Wed Jul 12 15:18:19 PDT 2023


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG83ad4cb61f4d: [InstCombine] Add tests for folding `(icmp eq/ne (zext i1) (sext i1))`; NFC (authored by goldstein.w.n).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D154573/new/

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.539759.patch
Type: text/x-patch
Size: 1713 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230712/9c647937/attachment.bin>


More information about the llvm-commits mailing list