[llvm] c05d574 - [InstCombine] add tests for min/max intrinsics with not ops; NFC

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 8 14:38:36 PST 2021


Author: Sanjay Patel
Date: 2021-03-08T17:38:23-05:00
New Revision: c05d574a98592228fdba7d350e9a1e4f40d18e2e

URL: https://github.com/llvm/llvm-project/commit/c05d574a98592228fdba7d350e9a1e4f40d18e2e
DIFF: https://github.com/llvm/llvm-project/commit/c05d574a98592228fdba7d350e9a1e4f40d18e2e.diff

LOG: [InstCombine] add tests for min/max intrinsics with not 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 4e3987f4640c..5d6d8eb2319b 100644
--- a/llvm/test/Transforms/InstCombine/minmax-intrinsics.ll
+++ b/llvm/test/Transforms/InstCombine/minmax-intrinsics.ll
@@ -377,3 +377,76 @@ define i8 @umin_zext_constanti_uses(i5 %x) {
   %m = call i8 @llvm.umin.i8(i8 %e, i8 7)
   ret i8 %m
 }
+
+define i8 @smax_of_nots(i8 %x, i8 %y) {
+; CHECK-LABEL: @smax_of_nots(
+; CHECK-NEXT:    [[NOTX:%.*]] = xor i8 [[X:%.*]], -1
+; CHECK-NEXT:    [[NOTY:%.*]] = xor i8 [[Y:%.*]], -1
+; CHECK-NEXT:    [[M:%.*]] = call i8 @llvm.smax.i8(i8 [[NOTX]], i8 [[NOTY]])
+; CHECK-NEXT:    ret i8 [[M]]
+;
+  %notx = xor i8 %x, -1
+  %noty = xor i8 %y, -1
+  %m = call i8 @llvm.smax.i8(i8 %notx, i8 %noty)
+  ret i8 %m
+}
+
+define <3 x i8> @smin_of_nots(<3 x i8> %x, <3 x i8> %y) {
+; CHECK-LABEL: @smin_of_nots(
+; CHECK-NEXT:    [[NOTX:%.*]] = xor <3 x i8> [[X:%.*]], <i8 -1, i8 undef, i8 -1>
+; CHECK-NEXT:    [[NOTY:%.*]] = xor <3 x i8> [[Y:%.*]], <i8 -1, i8 -1, i8 undef>
+; CHECK-NEXT:    [[M:%.*]] = call <3 x i8> @llvm.smin.v3i8(<3 x i8> [[NOTX]], <3 x i8> [[NOTY]])
+; CHECK-NEXT:    ret <3 x i8> [[M]]
+;
+  %notx = xor <3 x i8> %x, <i8 -1, i8 undef, i8 -1>
+  %noty = xor <3 x i8> %y, <i8 -1, i8 -1, i8 undef>
+  %m = call <3 x i8> @llvm.smin.v3i8(<3 x i8> %notx, <3 x i8> %noty)
+  ret <3 x i8> %m
+}
+
+define i8 @umax_of_nots(i8 %x, i8 %y) {
+; CHECK-LABEL: @umax_of_nots(
+; CHECK-NEXT:    [[NOTX:%.*]] = xor i8 [[X:%.*]], -1
+; CHECK-NEXT:    call void @use(i8 [[NOTX]])
+; CHECK-NEXT:    [[NOTY:%.*]] = xor i8 [[Y:%.*]], -1
+; CHECK-NEXT:    [[M:%.*]] = call i8 @llvm.umax.i8(i8 [[NOTX]], i8 [[NOTY]])
+; CHECK-NEXT:    ret i8 [[M]]
+;
+  %notx = xor i8 %x, -1
+  call void @use(i8 %notx)
+  %noty = xor i8 %y, -1
+  %m = call i8 @llvm.umax.i8(i8 %notx, i8 %noty)
+  ret i8 %m
+}
+
+define i8 @umin_of_nots(i8 %x, i8 %y) {
+; CHECK-LABEL: @umin_of_nots(
+; CHECK-NEXT:    [[NOTX:%.*]] = xor i8 [[X:%.*]], -1
+; CHECK-NEXT:    [[NOTY:%.*]] = xor i8 [[Y:%.*]], -1
+; CHECK-NEXT:    call void @use(i8 [[NOTY]])
+; CHECK-NEXT:    [[M:%.*]] = call i8 @llvm.umin.i8(i8 [[NOTX]], i8 [[NOTY]])
+; CHECK-NEXT:    ret i8 [[M]]
+;
+  %notx = xor i8 %x, -1
+  %noty = xor i8 %y, -1
+  call void @use(i8 %noty)
+  %m = call i8 @llvm.umin.i8(i8 %notx, i8 %noty)
+  ret i8 %m
+}
+
+define i8 @umin_of_nots_uses(i8 %x, i8 %y) {
+; CHECK-LABEL: @umin_of_nots_uses(
+; CHECK-NEXT:    [[NOTX:%.*]] = xor i8 [[X:%.*]], -1
+; CHECK-NEXT:    call void @use(i8 [[NOTX]])
+; CHECK-NEXT:    [[NOTY:%.*]] = xor i8 [[Y:%.*]], -1
+; CHECK-NEXT:    call void @use(i8 [[NOTY]])
+; CHECK-NEXT:    [[M:%.*]] = call i8 @llvm.umin.i8(i8 [[NOTX]], i8 [[NOTY]])
+; CHECK-NEXT:    ret i8 [[M]]
+;
+  %notx = xor i8 %x, -1
+  call void @use(i8 %notx)
+  %noty = xor i8 %y, -1
+  call void @use(i8 %noty)
+  %m = call i8 @llvm.umin.i8(i8 %notx, i8 %noty)
+  ret i8 %m
+}


        


More information about the llvm-commits mailing list