[llvm] 0751347 - [InstCombine] add tests for min/max with nots and sub; NFC
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Sat Aug 21 09:17:31 PDT 2021
Author: Sanjay Patel
Date: 2021-08-21T11:45:43-04:00
New Revision: 0751347bc36b7ba920102c5f8a33d4eb89c34343
URL: https://github.com/llvm/llvm-project/commit/0751347bc36b7ba920102c5f8a33d4eb89c34343
DIFF: https://github.com/llvm/llvm-project/commit/0751347bc36b7ba920102c5f8a33d4eb89c34343.diff
LOG: [InstCombine] add tests for min/max with nots and sub; 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 7816d5d6a32ee..2e4224b11ccf9 100644
--- a/llvm/test/Transforms/InstCombine/minmax-intrinsics.ll
+++ b/llvm/test/Transforms/InstCombine/minmax-intrinsics.ll
@@ -1149,6 +1149,54 @@ define i8 @neg_neg_nsw_umin(i8 %x, i8 %y) {
ret i8 %m
}
+define i8 @freeToInvertSub(i8 %x, i8 %y, i8 %z) {
+; CHECK-LABEL: @freeToInvertSub(
+; CHECK-NEXT: [[NX:%.*]] = xor i8 [[X:%.*]], -1
+; CHECK-NEXT: [[NY:%.*]] = xor i8 [[Y:%.*]], -1
+; CHECK-NEXT: [[NZ:%.*]] = xor i8 [[Z:%.*]], -1
+; CHECK-NEXT: call void @use(i8 [[NX]])
+; CHECK-NEXT: call void @use(i8 [[NY]])
+; CHECK-NEXT: call void @use(i8 [[NZ]])
+; CHECK-NEXT: [[M:%.*]] = call i8 @llvm.umax.i8(i8 [[NX]], i8 [[NY]])
+; CHECK-NEXT: [[SUB:%.*]] = sub i8 [[NZ]], [[M]]
+; CHECK-NEXT: ret i8 [[SUB]]
+;
+ %nx = xor i8 %x, -1
+ %ny = xor i8 %y, -1
+ %nz = xor i8 %z, -1
+ call void @use(i8 %nx)
+ call void @use(i8 %ny)
+ call void @use(i8 %nz)
+ %m = call i8 @llvm.umax.i8(i8 %nx, i8 %ny)
+ %sub = sub i8 %nz, %m
+ ret i8 %sub
+}
+
+define i8 @freeToInvertSub_uses(i8 %x, i8 %y, i8 %z) {
+; CHECK-LABEL: @freeToInvertSub_uses(
+; CHECK-NEXT: [[NX:%.*]] = xor i8 [[X:%.*]], -1
+; CHECK-NEXT: [[NY:%.*]] = xor i8 [[Y:%.*]], -1
+; CHECK-NEXT: [[NZ:%.*]] = xor i8 [[Z:%.*]], -1
+; CHECK-NEXT: call void @use(i8 [[NX]])
+; CHECK-NEXT: call void @use(i8 [[NY]])
+; CHECK-NEXT: call void @use(i8 [[NZ]])
+; CHECK-NEXT: [[M:%.*]] = call i8 @llvm.umax.i8(i8 [[NX]], i8 [[NY]])
+; CHECK-NEXT: call void @use(i8 [[M]])
+; CHECK-NEXT: [[SUB:%.*]] = sub i8 [[NZ]], [[M]]
+; CHECK-NEXT: ret i8 [[SUB]]
+;
+ %nx = xor i8 %x, -1
+ %ny = xor i8 %y, -1
+ %nz = xor i8 %z, -1
+ call void @use(i8 %nx)
+ call void @use(i8 %ny)
+ call void @use(i8 %nz)
+ %m = call i8 @llvm.umax.i8(i8 %nx, i8 %ny)
+ call void @use(i8 %m)
+ %sub = sub i8 %nz, %m
+ ret i8 %sub
+}
+
define i8 @freeToInvert(i8 %x, i8 %y, i8 %z) {
; CHECK-LABEL: @freeToInvert(
; CHECK-NEXT: [[NX:%.*]] = xor i8 [[X:%.*]], -1
More information about the llvm-commits
mailing list