[llvm] 781a438 - [InstSimplify] Add tests for min/max with dominating condition (NFC)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 4 14:46:04 PDT 2020
Author: Nikita Popov
Date: 2020-09-04T23:45:54+02:00
New Revision: 781a43840863b85603a710857691a9b5032b0c27
URL: https://github.com/llvm/llvm-project/commit/781a43840863b85603a710857691a9b5032b0c27
DIFF: https://github.com/llvm/llvm-project/commit/781a43840863b85603a710857691a9b5032b0c27.diff
LOG: [InstSimplify] Add tests for min/max with dominating condition (NFC)
Added:
Modified:
llvm/test/Transforms/InstSimplify/maxmin_intrinsics.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/InstSimplify/maxmin_intrinsics.ll b/llvm/test/Transforms/InstSimplify/maxmin_intrinsics.ll
index c2c0f9ebf82d..d1d711c1c1bd 100644
--- a/llvm/test/Transforms/InstSimplify/maxmin_intrinsics.ll
+++ b/llvm/test/Transforms/InstSimplify/maxmin_intrinsics.ll
@@ -2133,3 +2133,164 @@ define i8 @umax_lshr(i8 %x, i8 %y) {
%max = call i8 @llvm.umax.i8(i8 %x, i8 %shr)
ret i8 %max
}
+
+define i8 @umax_dom_cond_uge(i8 %x, i8 %y) {
+; CHECK-LABEL: @umax_dom_cond_uge(
+; CHECK-NEXT: [[CMP:%.*]] = icmp uge i8 [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT: br i1 [[CMP]], label [[TRUE:%.*]], label [[FALSE:%.*]]
+; CHECK: true:
+; CHECK-NEXT: [[M1:%.*]] = call i8 @llvm.umax.i8(i8 [[X]], i8 [[Y]])
+; CHECK-NEXT: ret i8 [[M1]]
+; CHECK: false:
+; CHECK-NEXT: [[M2:%.*]] = call i8 @llvm.umax.i8(i8 [[X]], i8 [[Y]])
+; CHECK-NEXT: ret i8 [[M2]]
+;
+ %cmp = icmp uge i8 %x, %y
+ br i1 %cmp, label %true, label %false
+
+true:
+ %m1 = call i8 @llvm.umax.i8(i8 %x, i8 %y)
+ ret i8 %m1
+
+false:
+ %m2 = call i8 @llvm.umax.i8(i8 %x, i8 %y)
+ ret i8 %m2
+}
+
+define i8 @umax_dom_cond_ugt(i8 %x, i8 %y) {
+; CHECK-LABEL: @umax_dom_cond_ugt(
+; CHECK-NEXT: [[CMP:%.*]] = icmp ugt i8 [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT: br i1 [[CMP]], label [[TRUE:%.*]], label [[FALSE:%.*]]
+; CHECK: true:
+; CHECK-NEXT: [[M1:%.*]] = call i8 @llvm.umax.i8(i8 [[X]], i8 [[Y]])
+; CHECK-NEXT: ret i8 [[M1]]
+; CHECK: false:
+; CHECK-NEXT: [[M2:%.*]] = call i8 @llvm.umax.i8(i8 [[X]], i8 [[Y]])
+; CHECK-NEXT: ret i8 [[M2]]
+;
+ %cmp = icmp ugt i8 %x, %y
+ br i1 %cmp, label %true, label %false
+
+true:
+ %m1 = call i8 @llvm.umax.i8(i8 %x, i8 %y)
+ ret i8 %m1
+
+false:
+ %m2 = call i8 @llvm.umax.i8(i8 %x, i8 %y)
+ ret i8 %m2
+}
+
+define i8 @umax_dom_cond_ule(i8 %x, i8 %y) {
+; CHECK-LABEL: @umax_dom_cond_ule(
+; CHECK-NEXT: [[CMP:%.*]] = icmp ule i8 [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT: br i1 [[CMP]], label [[TRUE:%.*]], label [[FALSE:%.*]]
+; CHECK: true:
+; CHECK-NEXT: [[M1:%.*]] = call i8 @llvm.umax.i8(i8 [[X]], i8 [[Y]])
+; CHECK-NEXT: ret i8 [[M1]]
+; CHECK: false:
+; CHECK-NEXT: [[M2:%.*]] = call i8 @llvm.umax.i8(i8 [[X]], i8 [[Y]])
+; CHECK-NEXT: ret i8 [[M2]]
+;
+ %cmp = icmp ule i8 %x, %y
+ br i1 %cmp, label %true, label %false
+
+true:
+ %m1 = call i8 @llvm.umax.i8(i8 %x, i8 %y)
+ ret i8 %m1
+
+false:
+ %m2 = call i8 @llvm.umax.i8(i8 %x, i8 %y)
+ ret i8 %m2
+}
+
+define i8 @umax_dom_cond_ult(i8 %x, i8 %y) {
+; CHECK-LABEL: @umax_dom_cond_ult(
+; CHECK-NEXT: [[CMP:%.*]] = icmp ult i8 [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT: br i1 [[CMP]], label [[TRUE:%.*]], label [[FALSE:%.*]]
+; CHECK: true:
+; CHECK-NEXT: [[M1:%.*]] = call i8 @llvm.umax.i8(i8 [[X]], i8 [[Y]])
+; CHECK-NEXT: ret i8 [[M1]]
+; CHECK: false:
+; CHECK-NEXT: [[M2:%.*]] = call i8 @llvm.umax.i8(i8 [[X]], i8 [[Y]])
+; CHECK-NEXT: ret i8 [[M2]]
+;
+ %cmp = icmp ult i8 %x, %y
+ br i1 %cmp, label %true, label %false
+
+true:
+ %m1 = call i8 @llvm.umax.i8(i8 %x, i8 %y)
+ ret i8 %m1
+
+false:
+ %m2 = call i8 @llvm.umax.i8(i8 %x, i8 %y)
+ ret i8 %m2
+}
+
+define i8 @umin_dom_cond_uge(i8 %x, i8 %y) {
+; CHECK-LABEL: @umin_dom_cond_uge(
+; CHECK-NEXT: [[CMP:%.*]] = icmp uge i8 [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT: br i1 [[CMP]], label [[TRUE:%.*]], label [[FALSE:%.*]]
+; CHECK: true:
+; CHECK-NEXT: [[M1:%.*]] = call i8 @llvm.umin.i8(i8 [[X]], i8 [[Y]])
+; CHECK-NEXT: ret i8 [[M1]]
+; CHECK: false:
+; CHECK-NEXT: [[M2:%.*]] = call i8 @llvm.umin.i8(i8 [[X]], i8 [[Y]])
+; CHECK-NEXT: ret i8 [[M2]]
+;
+ %cmp = icmp uge i8 %x, %y
+ br i1 %cmp, label %true, label %false
+
+true:
+ %m1 = call i8 @llvm.umin.i8(i8 %x, i8 %y)
+ ret i8 %m1
+
+false:
+ %m2 = call i8 @llvm.umin.i8(i8 %x, i8 %y)
+ ret i8 %m2
+}
+
+define i8 @smax_dom_cond_sge(i8 %x, i8 %y) {
+; CHECK-LABEL: @smax_dom_cond_sge(
+; CHECK-NEXT: [[CMP:%.*]] = icmp sge i8 [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT: br i1 [[CMP]], label [[TRUE:%.*]], label [[FALSE:%.*]]
+; CHECK: true:
+; CHECK-NEXT: [[M1:%.*]] = call i8 @llvm.smax.i8(i8 [[X]], i8 [[Y]])
+; CHECK-NEXT: ret i8 [[M1]]
+; CHECK: false:
+; CHECK-NEXT: [[M2:%.*]] = call i8 @llvm.smax.i8(i8 [[X]], i8 [[Y]])
+; CHECK-NEXT: ret i8 [[M2]]
+;
+ %cmp = icmp sge i8 %x, %y
+ br i1 %cmp, label %true, label %false
+
+true:
+ %m1 = call i8 @llvm.smax.i8(i8 %x, i8 %y)
+ ret i8 %m1
+
+false:
+ %m2 = call i8 @llvm.smax.i8(i8 %x, i8 %y)
+ ret i8 %m2
+}
+
+define i8 @smin_dom_cond_sge(i8 %x, i8 %y) {
+; CHECK-LABEL: @smin_dom_cond_sge(
+; CHECK-NEXT: [[CMP:%.*]] = icmp sge i8 [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT: br i1 [[CMP]], label [[TRUE:%.*]], label [[FALSE:%.*]]
+; CHECK: true:
+; CHECK-NEXT: [[M1:%.*]] = call i8 @llvm.smin.i8(i8 [[X]], i8 [[Y]])
+; CHECK-NEXT: ret i8 [[M1]]
+; CHECK: false:
+; CHECK-NEXT: [[M2:%.*]] = call i8 @llvm.smin.i8(i8 [[X]], i8 [[Y]])
+; CHECK-NEXT: ret i8 [[M2]]
+;
+ %cmp = icmp sge i8 %x, %y
+ br i1 %cmp, label %true, label %false
+
+true:
+ %m1 = call i8 @llvm.smin.i8(i8 %x, i8 %y)
+ ret i8 %m1
+
+false:
+ %m2 = call i8 @llvm.smin.i8(i8 %x, i8 %y)
+ ret i8 %m2
+}
More information about the llvm-commits
mailing list