[llvm] d7482a2 - [NFC][InstCombine] Add tests for smax reduction w/ i1 element type (PR51259)
Roman Lebedev via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 2 14:33:27 PDT 2021
Author: Roman Lebedev
Date: 2021-08-03T00:29:06+03:00
New Revision: d7482a2bded334710816ea0fc9fbbb6ec09d673e
URL: https://github.com/llvm/llvm-project/commit/d7482a2bded334710816ea0fc9fbbb6ec09d673e
DIFF: https://github.com/llvm/llvm-project/commit/d7482a2bded334710816ea0fc9fbbb6ec09d673e.diff
LOG: [NFC][InstCombine] Add tests for smax reduction w/ i1 element type (PR51259)
Added:
llvm/test/Transforms/InstCombine/reduction-smax-sext-zext-i1.ll
Modified:
Removed:
################################################################################
diff --git a/llvm/test/Transforms/InstCombine/reduction-smax-sext-zext-i1.ll b/llvm/test/Transforms/InstCombine/reduction-smax-sext-zext-i1.ll
new file mode 100644
index 000000000000..bf26a3276d75
--- /dev/null
+++ b/llvm/test/Transforms/InstCombine/reduction-smax-sext-zext-i1.ll
@@ -0,0 +1,93 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt < %s -instcombine -S | FileCheck %s
+
+define i1 @reduce_smax_self(<8 x i1> %x) {
+; CHECK-LABEL: @reduce_smax_self(
+; CHECK-NEXT: [[RES:%.*]] = call i1 @llvm.vector.reduce.smax.v8i1(<8 x i1> [[X:%.*]])
+; CHECK-NEXT: ret i1 [[RES]]
+;
+ %res = call i1 @llvm.vector.reduce.smax.v8i32(<8 x i1> %x)
+ ret i1 %res
+}
+
+define i32 @reduce_smax_sext(<4 x i1> %x) {
+; CHECK-LABEL: @reduce_smax_sext(
+; CHECK-NEXT: [[SEXT:%.*]] = sext <4 x i1> [[X:%.*]] to <4 x i32>
+; CHECK-NEXT: [[RES:%.*]] = call i32 @llvm.vector.reduce.smax.v4i32(<4 x i32> [[SEXT]])
+; CHECK-NEXT: ret i32 [[RES]]
+;
+ %sext = sext <4 x i1> %x to <4 x i32>
+ %res = call i32 @llvm.vector.reduce.smax.v4i32(<4 x i32> %sext)
+ ret i32 %res
+}
+
+define i64 @reduce_smax_zext(<8 x i1> %x) {
+; CHECK-LABEL: @reduce_smax_zext(
+; CHECK-NEXT: [[ZEXT:%.*]] = zext <8 x i1> [[X:%.*]] to <8 x i64>
+; CHECK-NEXT: [[RES:%.*]] = call i64 @llvm.vector.reduce.smax.v8i64(<8 x i64> [[ZEXT]])
+; CHECK-NEXT: ret i64 [[RES]]
+;
+ %zext = zext <8 x i1> %x to <8 x i64>
+ %res = call i64 @llvm.vector.reduce.smax.v8i64(<8 x i64> %zext)
+ ret i64 %res
+}
+
+define i16 @reduce_smax_sext_same(<16 x i1> %x) {
+; CHECK-LABEL: @reduce_smax_sext_same(
+; CHECK-NEXT: [[SEXT:%.*]] = sext <16 x i1> [[X:%.*]] to <16 x i16>
+; CHECK-NEXT: [[RES:%.*]] = call i16 @llvm.vector.reduce.smax.v16i16(<16 x i16> [[SEXT]])
+; CHECK-NEXT: ret i16 [[RES]]
+;
+ %sext = sext <16 x i1> %x to <16 x i16>
+ %res = call i16 @llvm.vector.reduce.smax.v16i16(<16 x i16> %sext)
+ ret i16 %res
+}
+
+define i8 @reduce_smax_zext_long(<128 x i1> %x) {
+; CHECK-LABEL: @reduce_smax_zext_long(
+; CHECK-NEXT: [[SEXT:%.*]] = sext <128 x i1> [[X:%.*]] to <128 x i8>
+; CHECK-NEXT: [[RES:%.*]] = call i8 @llvm.vector.reduce.smax.v128i8(<128 x i8> [[SEXT]])
+; CHECK-NEXT: ret i8 [[RES]]
+;
+ %sext = sext <128 x i1> %x to <128 x i8>
+ %res = call i8 @llvm.vector.reduce.smax.v128i8(<128 x i8> %sext)
+ ret i8 %res
+}
+
+ at glob = external global i8, align 1
+define i8 @reduce_smax_zext_long_external_use(<128 x i1> %x) {
+; CHECK-LABEL: @reduce_smax_zext_long_external_use(
+; CHECK-NEXT: [[SEXT:%.*]] = sext <128 x i1> [[X:%.*]] to <128 x i8>
+; CHECK-NEXT: [[RES:%.*]] = call i8 @llvm.vector.reduce.smax.v128i8(<128 x i8> [[SEXT]])
+; CHECK-NEXT: [[EXT:%.*]] = extractelement <128 x i8> [[SEXT]], i32 0
+; CHECK-NEXT: store i8 [[EXT]], i8* @glob, align 1
+; CHECK-NEXT: ret i8 [[RES]]
+;
+ %sext = sext <128 x i1> %x to <128 x i8>
+ %res = call i8 @llvm.vector.reduce.smax.v128i8(<128 x i8> %sext)
+ %ext = extractelement <128 x i8> %sext, i32 0
+ store i8 %ext, i8* @glob, align 1
+ ret i8 %res
+}
+
+ at glob1 = external global i64, align 8
+define i64 @reduce_smax_zext_external_use(<8 x i1> %x) {
+; CHECK-LABEL: @reduce_smax_zext_external_use(
+; CHECK-NEXT: [[ZEXT:%.*]] = zext <8 x i1> [[X:%.*]] to <8 x i64>
+; CHECK-NEXT: [[RES:%.*]] = call i64 @llvm.vector.reduce.smax.v8i64(<8 x i64> [[ZEXT]])
+; CHECK-NEXT: [[EXT:%.*]] = extractelement <8 x i64> [[ZEXT]], i32 0
+; CHECK-NEXT: store i64 [[EXT]], i64* @glob1, align 8
+; CHECK-NEXT: ret i64 [[RES]]
+;
+ %zext = zext <8 x i1> %x to <8 x i64>
+ %res = call i64 @llvm.vector.reduce.smax.v8i64(<8 x i64> %zext)
+ %ext = extractelement <8 x i64> %zext, i32 0
+ store i64 %ext, i64* @glob1, align 8
+ ret i64 %res
+}
+
+declare i1 @llvm.vector.reduce.smax.v8i32(<8 x i1> %a)
+declare i32 @llvm.vector.reduce.smax.v4i32(<4 x i32> %a)
+declare i64 @llvm.vector.reduce.smax.v8i64(<8 x i64> %a)
+declare i16 @llvm.vector.reduce.smax.v16i16(<16 x i16> %a)
+declare i8 @llvm.vector.reduce.smax.v128i8(<128 x i8> %a)
More information about the llvm-commits
mailing list