[llvm] c6cf711 - [InstSimplify] add tests for min/max intrinsics; NFC
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Sun Jul 26 06:04:55 PDT 2020
Author: Sanjay Patel
Date: 2020-07-26T09:04:37-04:00
New Revision: c6cf71107af8b8110572e8fe42d4624e1fc83549
URL: https://github.com/llvm/llvm-project/commit/c6cf71107af8b8110572e8fe42d4624e1fc83549
DIFF: https://github.com/llvm/llvm-project/commit/c6cf71107af8b8110572e8fe42d4624e1fc83549.diff
LOG: [InstSimplify] add tests for min/max intrinsics; NFC
Added:
llvm/test/Transforms/InstSimplify/maxmin_intrinsics.ll
Modified:
Removed:
################################################################################
diff --git a/llvm/test/Transforms/InstSimplify/maxmin_intrinsics.ll b/llvm/test/Transforms/InstSimplify/maxmin_intrinsics.ll
new file mode 100644
index 000000000000..fe940ef7bc17
--- /dev/null
+++ b/llvm/test/Transforms/InstSimplify/maxmin_intrinsics.ll
@@ -0,0 +1,83 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt < %s -instsimplify -S | FileCheck %s
+
+declare i8 @llvm.smax.i8(i8, i8)
+declare <2 x i8> @llvm.smax.v2i8(<2 x i8>, <2 x i8>)
+declare i8 @llvm.smin.i8(i8, i8)
+declare <2 x i8> @llvm.smin.v2i8(<2 x i8>, <2 x i8>)
+declare i8 @llvm.umax.i8(i8, i8)
+declare <2 x i8> @llvm.umax.v2i8(<2 x i8>, <2 x i8>)
+declare i8 @llvm.umin.i8(i8, i8)
+declare <2 x i8> @llvm.umin.v2i8(<2 x i8>, <2 x i8>)
+
+define i8 @smax_maxval(i8 %x) {
+; CHECK-LABEL: @smax_maxval(
+; CHECK-NEXT: [[R:%.*]] = call i8 @llvm.smax.i8(i8 [[X:%.*]], i8 127)
+; CHECK-NEXT: ret i8 [[R]]
+;
+ %r = call i8 @llvm.smax.i8(i8 %x, i8 127)
+ ret i8 %r
+}
+
+define <2 x i8> @smax_maxval_commute(<2 x i8> %x) {
+; CHECK-LABEL: @smax_maxval_commute(
+; CHECK-NEXT: [[R:%.*]] = call <2 x i8> @llvm.smax.v2i8(<2 x i8> <i8 127, i8 127>, <2 x i8> [[X:%.*]])
+; CHECK-NEXT: ret <2 x i8> [[R]]
+;
+ %r = call <2 x i8> @llvm.smax.v2i8(<2 x i8> <i8 127, i8 127>, <2 x i8> %x)
+ ret <2 x i8> %r
+}
+
+define i8 @smin_minval(i8 %x) {
+; CHECK-LABEL: @smin_minval(
+; CHECK-NEXT: [[R:%.*]] = call i8 @llvm.smin.i8(i8 -128, i8 [[X:%.*]])
+; CHECK-NEXT: ret i8 [[R]]
+;
+ %r = call i8 @llvm.smin.i8(i8 -128, i8 %x)
+ ret i8 %r
+}
+
+define <2 x i8> @smin_minval_commute(<2 x i8> %x) {
+; CHECK-LABEL: @smin_minval_commute(
+; CHECK-NEXT: [[R:%.*]] = call <2 x i8> @llvm.smin.v2i8(<2 x i8> [[X:%.*]], <2 x i8> <i8 -128, i8 -128>)
+; CHECK-NEXT: ret <2 x i8> [[R]]
+;
+ %r = call <2 x i8> @llvm.smin.v2i8(<2 x i8> %x, <2 x i8> <i8 -128, i8 -128>)
+ ret <2 x i8> %r
+}
+
+define i8 @umax_maxval(i8 %x) {
+; CHECK-LABEL: @umax_maxval(
+; CHECK-NEXT: [[R:%.*]] = call i8 @llvm.umax.i8(i8 [[X:%.*]], i8 -1)
+; CHECK-NEXT: ret i8 [[R]]
+;
+ %r = call i8 @llvm.umax.i8(i8 %x, i8 255)
+ ret i8 %r
+}
+
+define <2 x i8> @umax_maxval_commute(<2 x i8> %x) {
+; CHECK-LABEL: @umax_maxval_commute(
+; CHECK-NEXT: [[R:%.*]] = call <2 x i8> @llvm.umax.v2i8(<2 x i8> <i8 -1, i8 -1>, <2 x i8> [[X:%.*]])
+; CHECK-NEXT: ret <2 x i8> [[R]]
+;
+ %r = call <2 x i8> @llvm.umax.v2i8(<2 x i8> <i8 255, i8 255>, <2 x i8> %x)
+ ret <2 x i8> %r
+}
+
+define i8 @umin_minval(i8 %x) {
+; CHECK-LABEL: @umin_minval(
+; CHECK-NEXT: [[R:%.*]] = call i8 @llvm.umin.i8(i8 0, i8 [[X:%.*]])
+; CHECK-NEXT: ret i8 [[R]]
+;
+ %r = call i8 @llvm.umin.i8(i8 0, i8 %x)
+ ret i8 %r
+}
+
+define <2 x i8> @umin_minval_commute(<2 x i8> %x) {
+; CHECK-LABEL: @umin_minval_commute(
+; CHECK-NEXT: [[R:%.*]] = call <2 x i8> @llvm.umin.v2i8(<2 x i8> [[X:%.*]], <2 x i8> zeroinitializer)
+; CHECK-NEXT: ret <2 x i8> [[R]]
+;
+ %r = call <2 x i8> @llvm.umin.v2i8(<2 x i8> %x, <2 x i8> zeroinitializer)
+ ret <2 x i8> %r
+}
More information about the llvm-commits
mailing list