[llvm] 8fb269d - [InstCombine] add tests for smin/smax intrinsics with negated ops; NFC
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 17 05:16:23 PDT 2021
Author: Sanjay Patel
Date: 2021-08-17T08:10:42-04:00
New Revision: 8fb269d94075c70b676ff8b7c8baf695cc66c74f
URL: https://github.com/llvm/llvm-project/commit/8fb269d94075c70b676ff8b7c8baf695cc66c74f
DIFF: https://github.com/llvm/llvm-project/commit/8fb269d94075c70b676ff8b7c8baf695cc66c74f.diff
LOG: [InstCombine] add tests for smin/smax intrinsics with negated ops; NFC
Added:
Modified:
llvm/test/Transforms/InstCombine/minmax-intrinsics.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/InstCombine/minmax-intrinsics.ll b/llvm/test/Transforms/InstCombine/minmax-intrinsics.ll
index c21724b46308..a3dbbc9dcbde 100644
--- a/llvm/test/Transforms/InstCombine/minmax-intrinsics.ll
+++ b/llvm/test/Transforms/InstCombine/minmax-intrinsics.ll
@@ -1030,3 +1030,115 @@ define i8 @umin_demand_and_7_8(i8 %x) {
%r = and i8 %m, -8
ret i8 %r
}
+
+define i8 @neg_neg_nsw_smax(i8 %x, i8 %y) {
+; CHECK-LABEL: @neg_neg_nsw_smax(
+; CHECK-NEXT: [[NX:%.*]] = sub nsw i8 0, [[X:%.*]]
+; CHECK-NEXT: [[NY:%.*]] = sub nsw i8 0, [[Y:%.*]]
+; CHECK-NEXT: [[M:%.*]] = call i8 @llvm.smax.i8(i8 [[NX]], i8 [[NY]])
+; CHECK-NEXT: ret i8 [[M]]
+;
+ %nx = sub nsw i8 0, %x
+ %ny = sub nsw i8 0, %y
+ %m = call i8 @llvm.smax.i8(i8 %nx, i8 %ny)
+ ret i8 %m
+}
+
+define <3 x i8> @neg_neg_nsw_smin(<3 x i8> %x, <3 x i8> %y) {
+; CHECK-LABEL: @neg_neg_nsw_smin(
+; CHECK-NEXT: [[NX:%.*]] = sub nsw <3 x i8> zeroinitializer, [[X:%.*]]
+; CHECK-NEXT: [[NY:%.*]] = sub nsw <3 x i8> zeroinitializer, [[Y:%.*]]
+; CHECK-NEXT: [[M:%.*]] = call <3 x i8> @llvm.smin.v3i8(<3 x i8> [[NX]], <3 x i8> [[NY]])
+; CHECK-NEXT: ret <3 x i8> [[M]]
+;
+ %nx = sub nsw <3 x i8> zeroinitializer, %x
+ %ny = sub nsw <3 x i8> zeroinitializer, %y
+ %m = call <3 x i8> @llvm.smin.v3i8(<3 x i8> %nx, <3 x i8> %ny)
+ ret <3 x i8> %m
+}
+
+define i8 @neg_neg_nsw_smax_use0(i8 %x, i8 %y) {
+; CHECK-LABEL: @neg_neg_nsw_smax_use0(
+; CHECK-NEXT: [[NX:%.*]] = sub nsw i8 0, [[X:%.*]]
+; CHECK-NEXT: call void @use(i8 [[NX]])
+; CHECK-NEXT: [[NY:%.*]] = sub nsw i8 0, [[Y:%.*]]
+; CHECK-NEXT: [[M:%.*]] = call i8 @llvm.smax.i8(i8 [[NX]], i8 [[NY]])
+; CHECK-NEXT: ret i8 [[M]]
+;
+ %nx = sub nsw i8 0, %x
+ call void @use(i8 %nx)
+ %ny = sub nsw i8 0, %y
+ %m = call i8 @llvm.smax.i8(i8 %nx, i8 %ny)
+ ret i8 %m
+}
+
+define i8 @neg_neg_nsw_smin_use1(i8 %x, i8 %y) {
+; CHECK-LABEL: @neg_neg_nsw_smin_use1(
+; CHECK-NEXT: [[NX:%.*]] = sub nsw i8 0, [[X:%.*]]
+; CHECK-NEXT: [[NY:%.*]] = sub nsw i8 0, [[Y:%.*]]
+; CHECK-NEXT: call void @use(i8 [[NY]])
+; CHECK-NEXT: [[M:%.*]] = call i8 @llvm.smin.i8(i8 [[NX]], i8 [[NY]])
+; CHECK-NEXT: ret i8 [[M]]
+;
+ %nx = sub nsw i8 0, %x
+ %ny = sub nsw i8 0, %y
+ call void @use(i8 %ny)
+ %m = call i8 @llvm.smin.i8(i8 %nx, i8 %ny)
+ ret i8 %m
+}
+
+define i8 @neg_neg_nsw_smin_use2(i8 %x, i8 %y) {
+; CHECK-LABEL: @neg_neg_nsw_smin_use2(
+; CHECK-NEXT: [[NX:%.*]] = sub nsw i8 0, [[X:%.*]]
+; CHECK-NEXT: call void @use(i8 [[NX]])
+; CHECK-NEXT: [[NY:%.*]] = sub nsw i8 0, [[Y:%.*]]
+; CHECK-NEXT: call void @use(i8 [[NY]])
+; CHECK-NEXT: [[M:%.*]] = call i8 @llvm.smin.i8(i8 [[NX]], i8 [[NY]])
+; CHECK-NEXT: ret i8 [[M]]
+;
+ %nx = sub nsw i8 0, %x
+ call void @use(i8 %nx)
+ %ny = sub nsw i8 0, %y
+ call void @use(i8 %ny)
+ %m = call i8 @llvm.smin.i8(i8 %nx, i8 %ny)
+ ret i8 %m
+}
+
+define i8 @neg_neg_smax(i8 %x, i8 %y) {
+; CHECK-LABEL: @neg_neg_smax(
+; CHECK-NEXT: [[NX:%.*]] = sub i8 0, [[X:%.*]]
+; CHECK-NEXT: [[NY:%.*]] = sub nsw i8 0, [[Y:%.*]]
+; CHECK-NEXT: [[M:%.*]] = call i8 @llvm.smax.i8(i8 [[NX]], i8 [[NY]])
+; CHECK-NEXT: ret i8 [[M]]
+;
+ %nx = sub i8 0, %x
+ %ny = sub nsw i8 0, %y
+ %m = call i8 @llvm.smax.i8(i8 %nx, i8 %ny)
+ ret i8 %m
+}
+
+define i8 @neg_neg_smin(i8 %x, i8 %y) {
+; CHECK-LABEL: @neg_neg_smin(
+; CHECK-NEXT: [[NX:%.*]] = sub i8 0, [[X:%.*]]
+; CHECK-NEXT: [[NY:%.*]] = sub nsw i8 0, [[Y:%.*]]
+; CHECK-NEXT: [[M:%.*]] = call i8 @llvm.smin.i8(i8 [[NX]], i8 [[NY]])
+; CHECK-NEXT: ret i8 [[M]]
+;
+ %nx = sub i8 0, %x
+ %ny = sub nsw i8 0, %y
+ %m = call i8 @llvm.smin.i8(i8 %nx, i8 %ny)
+ ret i8 %m
+}
+
+define i8 @neg_neg_nsw_umin(i8 %x, i8 %y) {
+; CHECK-LABEL: @neg_neg_nsw_umin(
+; CHECK-NEXT: [[NX:%.*]] = sub nsw i8 0, [[X:%.*]]
+; CHECK-NEXT: [[NY:%.*]] = sub nsw i8 0, [[Y:%.*]]
+; CHECK-NEXT: [[M:%.*]] = call i8 @llvm.umin.i8(i8 [[NX]], i8 [[NY]])
+; CHECK-NEXT: ret i8 [[M]]
+;
+ %nx = sub nsw i8 0, %x
+ %ny = sub nsw i8 0, %y
+ %m = call i8 @llvm.umin.i8(i8 %nx, i8 %ny)
+ ret i8 %m
+}
More information about the llvm-commits
mailing list