[llvm] f3c39ee - [InstCombine] add tests for vector cmp-bitcast; NFC
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 29 16:10:20 PDT 2021
Author: Sanjay Patel
Date: 2021-07-29T19:09:44-04:00
New Revision: f3c39ee84ad6950035a6083c076fdebddebefb04
URL: https://github.com/llvm/llvm-project/commit/f3c39ee84ad6950035a6083c076fdebddebefb04
DIFF: https://github.com/llvm/llvm-project/commit/f3c39ee84ad6950035a6083c076fdebddebefb04.diff
LOG: [InstCombine] add tests for vector cmp-bitcast; NFC
Added:
Modified:
llvm/test/Transforms/InstCombine/icmp-vec.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/InstCombine/icmp-vec.ll b/llvm/test/Transforms/InstCombine/icmp-vec.ll
index 13690a800efcd..ba56d5e51ba8c 100644
--- a/llvm/test/Transforms/InstCombine/icmp-vec.ll
+++ b/llvm/test/Transforms/InstCombine/icmp-vec.ll
@@ -399,3 +399,110 @@ define <vscale x 2 x i1> @icmp_logical_or_scalablevec(<vscale x 2 x i64> %x, <vs
%sel = select <vscale x 2 x i1> %cmp.ne, <vscale x 2 x i1> shufflevector (<vscale x 2 x i1> insertelement (<vscale x 2 x i1> undef, i1 true, i32 0), <vscale x 2 x i1> undef, <vscale x 2 x i32> zeroinitializer), <vscale x 2 x i1> %falseval
ret <vscale x 2 x i1> %sel
}
+
+define i1 @eq_cast_eq-1(<2 x i4> %x, <2 x i4> %y) {
+; CHECK-LABEL: @eq_cast_eq-1(
+; CHECK-NEXT: [[NZ:%.*]] = icmp eq <2 x i4> [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT: [[B:%.*]] = bitcast <2 x i1> [[NZ]] to i2
+; CHECK-NEXT: [[R:%.*]] = icmp eq i2 [[B]], -1
+; CHECK-NEXT: ret i1 [[R]]
+;
+ %nz = icmp eq <2 x i4> %x, %y
+ %b = bitcast <2 x i1> %nz to i2
+ %r = icmp eq i2 %b, -1
+ ret i1 %r
+}
+
+define i1 @ne_cast_eq-1(<3 x i7> %x, <3 x i7> %y) {
+; CHECK-LABEL: @ne_cast_eq-1(
+; CHECK-NEXT: [[NZ:%.*]] = icmp ne <3 x i7> [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT: [[B:%.*]] = bitcast <3 x i1> [[NZ]] to i3
+; CHECK-NEXT: [[R:%.*]] = icmp eq i3 [[B]], -1
+; CHECK-NEXT: ret i1 [[R]]
+;
+ %nz = icmp ne <3 x i7> %x, %y
+ %b = bitcast <3 x i1> %nz to i3
+ %r = icmp eq i3 %b, -1
+ ret i1 %r
+}
+
+define i1 @eq_cast_ne-1(<2 x i7> %x, <2 x i7> %y) {
+; CHECK-LABEL: @eq_cast_ne-1(
+; CHECK-NEXT: [[NZ:%.*]] = icmp eq <2 x i7> [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT: [[B:%.*]] = bitcast <2 x i1> [[NZ]] to i2
+; CHECK-NEXT: [[R:%.*]] = icmp ne i2 [[B]], -1
+; CHECK-NEXT: ret i1 [[R]]
+;
+ %nz = icmp eq <2 x i7> %x, %y
+ %b = bitcast <2 x i1> %nz to i2
+ %r = icmp ne i2 %b, -1
+ ret i1 %r
+}
+
+define i1 @ne_cast_ne-1(<3 x i5> %x, <3 x i5> %y) {
+; CHECK-LABEL: @ne_cast_ne-1(
+; CHECK-NEXT: [[NZ:%.*]] = icmp ne <3 x i5> [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT: [[B:%.*]] = bitcast <3 x i1> [[NZ]] to i3
+; CHECK-NEXT: [[R:%.*]] = icmp ne i3 [[B]], -1
+; CHECK-NEXT: ret i1 [[R]]
+;
+ %nz = icmp ne <3 x i5> %x, %y
+ %b = bitcast <3 x i1> %nz to i3
+ %r = icmp ne i3 %b, -1
+ ret i1 %r
+}
+
+define i1 @ugt_cast_eq-1(<2 x i4> %x, <2 x i4> %y) {
+; CHECK-LABEL: @ugt_cast_eq-1(
+; CHECK-NEXT: [[NZ:%.*]] = icmp ugt <2 x i4> [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT: [[B:%.*]] = bitcast <2 x i1> [[NZ]] to i2
+; CHECK-NEXT: [[R:%.*]] = icmp eq i2 [[B]], -1
+; CHECK-NEXT: ret i1 [[R]]
+;
+ %nz = icmp ugt <2 x i4> %x, %y
+ %b = bitcast <2 x i1> %nz to i2
+ %r = icmp eq i2 %b, -1
+ ret i1 %r
+}
+
+define i1 @eq_cast_sgt-1(<3 x i4> %x, <3 x i4> %y) {
+; CHECK-LABEL: @eq_cast_sgt-1(
+; CHECK-NEXT: [[NZ:%.*]] = icmp eq <3 x i4> [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT: [[B:%.*]] = bitcast <3 x i1> [[NZ]] to i3
+; CHECK-NEXT: [[R:%.*]] = icmp sgt i3 [[B]], -1
+; CHECK-NEXT: ret i1 [[R]]
+;
+ %nz = icmp eq <3 x i4> %x, %y
+ %b = bitcast <3 x i1> %nz to i3
+ %r = icmp sgt i3 %b, -1
+ ret i1 %r
+}
+
+define i1 @eq_cast_eq1(<2 x i4> %x, <2 x i4> %y) {
+; CHECK-LABEL: @eq_cast_eq1(
+; CHECK-NEXT: [[NZ:%.*]] = icmp eq <2 x i4> [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT: [[B:%.*]] = bitcast <2 x i1> [[NZ]] to i2
+; CHECK-NEXT: [[R:%.*]] = icmp eq i2 [[B]], 1
+; CHECK-NEXT: ret i1 [[R]]
+;
+ %nz = icmp eq <2 x i4> %x, %y
+ %b = bitcast <2 x i1> %nz to i2
+ %r = icmp eq i2 %b, 1
+ ret i1 %r
+}
+
+define i1 @eq_cast_eq-1_use(<2 x i4> %x, <2 x i4> %y, i2* %p) {
+; CHECK-LABEL: @eq_cast_eq-1_use(
+; CHECK-NEXT: [[NZ:%.*]] = icmp sgt <2 x i4> [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT: [[B:%.*]] = bitcast <2 x i1> [[NZ]] to i2
+; CHECK-NEXT: [[TMP1:%.*]] = bitcast i2* [[P:%.*]] to <2 x i1>*
+; CHECK-NEXT: store <2 x i1> [[NZ]], <2 x i1>* [[TMP1]], align 1
+; CHECK-NEXT: [[R:%.*]] = icmp eq i2 [[B]], -1
+; CHECK-NEXT: ret i1 [[R]]
+;
+ %nz = icmp sgt <2 x i4> %x, %y
+ %b = bitcast <2 x i1> %nz to i2
+ store i2 %b, i2* %p
+ %r = icmp eq i2 %b, -1
+ ret i1 %r
+}
More information about the llvm-commits
mailing list