[InstSimplify] Add additional icmp of min/max tests; NFC

These are baseline tests for D59506.

llvm-svn: 356408
This commit is contained in:
Nikita Popov 2019-03-18 21:19:56 +00:00
parent f086e562f9
commit 05baa9ee1a
1 changed files with 150 additions and 0 deletions

View File

@ -0,0 +1,150 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt < %s -instsimplify -S | FileCheck %s
define i1 @test_umax1(i32 %n) {
; CHECK-LABEL: @test_umax1(
; CHECK-NEXT: [[C1:%.*]] = icmp ugt i32 [[N:%.*]], 10
; CHECK-NEXT: [[S:%.*]] = select i1 [[C1]], i32 [[N]], i32 10
; CHECK-NEXT: [[C2:%.*]] = icmp ugt i32 [[S]], 9
; CHECK-NEXT: ret i1 [[C2]]
;
%c1 = icmp ugt i32 %n, 10
%s = select i1 %c1, i32 %n, i32 10
%c2 = icmp ugt i32 %s, 9
ret i1 %c2
}
define i1 @test_umax2(i32 %n) {
; CHECK-LABEL: @test_umax2(
; CHECK-NEXT: [[C1:%.*]] = icmp ugt i32 [[N:%.*]], 10
; CHECK-NEXT: ret i1 [[C1]]
;
%c1 = icmp ugt i32 %n, 10
%s = select i1 %c1, i32 %n, i32 10
%c2 = icmp ugt i32 %s, 10
ret i1 %c2
}
define i1 @test_umax3(i32 %n) {
; CHECK-LABEL: @test_umax3(
; CHECK-NEXT: [[C1:%.*]] = icmp ugt i32 [[N:%.*]], 10
; CHECK-NEXT: [[S:%.*]] = select i1 [[C1]], i32 [[N]], i32 10
; CHECK-NEXT: [[C2:%.*]] = icmp ugt i32 [[S]], 11
; CHECK-NEXT: ret i1 [[C2]]
;
%c1 = icmp ugt i32 %n, 10
%s = select i1 %c1, i32 %n, i32 10
%c2 = icmp ugt i32 %s, 11
ret i1 %c2
}
define i1 @test_umin1(i32 %n) {
; CHECK-LABEL: @test_umin1(
; CHECK-NEXT: [[C1:%.*]] = icmp ult i32 [[N:%.*]], 10
; CHECK-NEXT: [[S:%.*]] = select i1 [[C1]], i32 [[N]], i32 10
; CHECK-NEXT: [[C2:%.*]] = icmp ult i32 [[S]], 11
; CHECK-NEXT: ret i1 [[C2]]
;
%c1 = icmp ult i32 %n, 10
%s = select i1 %c1, i32 %n, i32 10
%c2 = icmp ult i32 %s, 11
ret i1 %c2
}
define i1 @test_umin2(i32 %n) {
; CHECK-LABEL: @test_umin2(
; CHECK-NEXT: [[C1:%.*]] = icmp ult i32 [[N:%.*]], 10
; CHECK-NEXT: ret i1 [[C1]]
;
%c1 = icmp ult i32 %n, 10
%s = select i1 %c1, i32 %n, i32 10
%c2 = icmp ult i32 %s, 10
ret i1 %c2
}
define i1 @test_umin3(i32 %n) {
; CHECK-LABEL: @test_umin3(
; CHECK-NEXT: [[C1:%.*]] = icmp ult i32 [[N:%.*]], 10
; CHECK-NEXT: [[S:%.*]] = select i1 [[C1]], i32 [[N]], i32 10
; CHECK-NEXT: [[C2:%.*]] = icmp ult i32 [[S]], 9
; CHECK-NEXT: ret i1 [[C2]]
;
%c1 = icmp ult i32 %n, 10
%s = select i1 %c1, i32 %n, i32 10
%c2 = icmp ult i32 %s, 9
ret i1 %c2
}
define i1 @test_smax1(i32 %n) {
; CHECK-LABEL: @test_smax1(
; CHECK-NEXT: [[C1:%.*]] = icmp sgt i32 [[N:%.*]], -10
; CHECK-NEXT: [[S:%.*]] = select i1 [[C1]], i32 [[N]], i32 -10
; CHECK-NEXT: [[C2:%.*]] = icmp sgt i32 [[S]], -11
; CHECK-NEXT: ret i1 [[C2]]
;
%c1 = icmp sgt i32 %n, -10
%s = select i1 %c1, i32 %n, i32 -10
%c2 = icmp sgt i32 %s, -11
ret i1 %c2
}
define i1 @test_smax2(i32 %n) {
; CHECK-LABEL: @test_smax2(
; CHECK-NEXT: [[C1:%.*]] = icmp sgt i32 [[N:%.*]], -10
; CHECK-NEXT: ret i1 [[C1]]
;
%c1 = icmp sgt i32 %n, -10
%s = select i1 %c1, i32 %n, i32 -10
%c2 = icmp sgt i32 %s, -10
ret i1 %c2
}
define i1 @test_smax3(i32 %n) {
; CHECK-LABEL: @test_smax3(
; CHECK-NEXT: [[C1:%.*]] = icmp sgt i32 [[N:%.*]], -10
; CHECK-NEXT: [[S:%.*]] = select i1 [[C1]], i32 [[N]], i32 -10
; CHECK-NEXT: [[C2:%.*]] = icmp sgt i32 [[S]], -9
; CHECK-NEXT: ret i1 [[C2]]
;
%c1 = icmp sgt i32 %n, -10
%s = select i1 %c1, i32 %n, i32 -10
%c2 = icmp sgt i32 %s, -9
ret i1 %c2
}
define i1 @test_smin1(i32 %n) {
; CHECK-LABEL: @test_smin1(
; CHECK-NEXT: [[C1:%.*]] = icmp slt i32 [[N:%.*]], 10
; CHECK-NEXT: [[S:%.*]] = select i1 [[C1]], i32 [[N]], i32 10
; CHECK-NEXT: [[C2:%.*]] = icmp slt i32 [[S]], 11
; CHECK-NEXT: ret i1 [[C2]]
;
%c1 = icmp slt i32 %n, 10
%s = select i1 %c1, i32 %n, i32 10
%c2 = icmp slt i32 %s, 11
ret i1 %c2
}
define i1 @test_smin2(i32 %n) {
; CHECK-LABEL: @test_smin2(
; CHECK-NEXT: [[C1:%.*]] = icmp slt i32 [[N:%.*]], 10
; CHECK-NEXT: ret i1 [[C1]]
;
%c1 = icmp slt i32 %n, 10
%s = select i1 %c1, i32 %n, i32 10
%c2 = icmp slt i32 %s, 10
ret i1 %c2
}
define i1 @test_smin3(i32 %n) {
; CHECK-LABEL: @test_smin3(
; CHECK-NEXT: [[C1:%.*]] = icmp slt i32 [[N:%.*]], 10
; CHECK-NEXT: [[S:%.*]] = select i1 [[C1]], i32 [[N]], i32 10
; CHECK-NEXT: [[C2:%.*]] = icmp slt i32 [[S]], 9
; CHECK-NEXT: ret i1 [[C2]]
;
%c1 = icmp slt i32 %n, 10
%s = select i1 %c1, i32 %n, i32 10
%c2 = icmp slt i32 %s, 9
ret i1 %c2
}