[llvm] ef19f6c - [InstCombine] add tests for min/max intrinsics with not+constant; NFC

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 9 08:39:48 PST 2021


Author: Sanjay Patel
Date: 2021-03-09T11:33:28-05:00
New Revision: ef19f6cbf333ec1558a0dee49c52b9824778a660

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

LOG: [InstCombine] add tests for min/max intrinsics with not+constant; 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 94cfea53e965..06154401a5ae 100644
--- a/llvm/test/Transforms/InstCombine/minmax-intrinsics.ll
+++ b/llvm/test/Transforms/InstCombine/minmax-intrinsics.ll
@@ -456,3 +456,60 @@ define i8 @umin_of_nots_uses(i8 %x, i8 %y) {
   %m = call i8 @llvm.umin.i8(i8 %notx, i8 %noty)
   ret i8 %m
 }
+
+define i8 @smax_of_not_and_const(i8 %x) {
+; CHECK-LABEL: @smax_of_not_and_const(
+; CHECK-NEXT:    [[NOTX:%.*]] = xor i8 [[X:%.*]], -1
+; CHECK-NEXT:    [[M:%.*]] = call i8 @llvm.smax.i8(i8 [[NOTX]], i8 42)
+; CHECK-NEXT:    ret i8 [[M]]
+;
+  %notx = xor i8 %x, -1
+  %m = call i8 @llvm.smax.i8(i8 %notx, i8 42)
+  ret i8 %m
+}
+
+define <3 x i8> @smin_of_not_and_const(<3 x i8> %x) {
+; CHECK-LABEL: @smin_of_not_and_const(
+; CHECK-NEXT:    [[NOTX:%.*]] = xor <3 x i8> [[X:%.*]], <i8 -1, i8 -1, i8 undef>
+; CHECK-NEXT:    [[M:%.*]] = call <3 x i8> @llvm.smin.v3i8(<3 x i8> [[NOTX]], <3 x i8> <i8 42, i8 undef, i8 43>)
+; CHECK-NEXT:    ret <3 x i8> [[M]]
+;
+  %notx = xor <3 x i8> %x, <i8 -1, i8 -1, i8 undef>
+  %m = call <3 x i8> @llvm.smin.v3i8(<3 x i8> <i8 42, i8 undef, i8 43>, <3 x i8> %notx)
+  ret <3 x i8> %m
+}
+
+define i8 @umax_of_not_and_const(i8 %x) {
+; CHECK-LABEL: @umax_of_not_and_const(
+; CHECK-NEXT:    [[NOTX:%.*]] = xor i8 [[X:%.*]], -1
+; CHECK-NEXT:    [[M:%.*]] = call i8 @llvm.umax.i8(i8 [[NOTX]], i8 44)
+; CHECK-NEXT:    ret i8 [[M]]
+;
+  %notx = xor i8 %x, -1
+  %m = call i8 @llvm.umax.i8(i8 %notx, i8 44)
+  ret i8 %m
+}
+
+define i8 @umin_of_not_and_const(i8 %x) {
+; CHECK-LABEL: @umin_of_not_and_const(
+; CHECK-NEXT:    [[NOTX:%.*]] = xor i8 [[X:%.*]], -1
+; CHECK-NEXT:    [[M:%.*]] = call i8 @llvm.umin.i8(i8 [[NOTX]], i8 -45)
+; CHECK-NEXT:    ret i8 [[M]]
+;
+  %notx = xor i8 %x, -1
+  %m = call i8 @llvm.umin.i8(i8 -45, i8 %notx)
+  ret i8 %m
+}
+
+define i8 @umin_of_not_and_const_uses(i8 %x) {
+; CHECK-LABEL: @umin_of_not_and_const_uses(
+; CHECK-NEXT:    [[NOTX:%.*]] = xor i8 [[X:%.*]], -1
+; CHECK-NEXT:    call void @use(i8 [[NOTX]])
+; CHECK-NEXT:    [[M:%.*]] = call i8 @llvm.umin.i8(i8 [[NOTX]], i8 -45)
+; CHECK-NEXT:    ret i8 [[M]]
+;
+  %notx = xor i8 %x, -1
+  call void @use(i8 %notx)
+  %m = call i8 @llvm.umin.i8(i8 -45, i8 %notx)
+  ret i8 %m
+}


        


More information about the llvm-commits mailing list