1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -passes=instsimplify -S | FileCheck %s
4 define i1 @test_umax1(i32 %n) {
5 ; CHECK-LABEL: @test_umax1(
6 ; CHECK-NEXT: ret i1 true
8 %c1 = icmp ugt i32 %n, 10
9 %s = select i1 %c1, i32 %n, i32 10
10 %c2 = icmp ugt i32 %s, 9
14 define i1 @test_umax2(i32 %n) {
15 ; CHECK-LABEL: @test_umax2(
16 ; CHECK-NEXT: [[C1:%.*]] = icmp ugt i32 [[N:%.*]], 10
17 ; CHECK-NEXT: ret i1 [[C1]]
19 %c1 = icmp ugt i32 %n, 10
20 %s = select i1 %c1, i32 %n, i32 10
21 %c2 = icmp ugt i32 %s, 10
25 define i1 @test_umax3(i32 %n) {
26 ; CHECK-LABEL: @test_umax3(
27 ; CHECK-NEXT: [[C1:%.*]] = icmp ugt i32 [[N:%.*]], 10
28 ; CHECK-NEXT: [[S:%.*]] = select i1 [[C1]], i32 [[N]], i32 10
29 ; CHECK-NEXT: [[C2:%.*]] = icmp ugt i32 [[S]], 11
30 ; CHECK-NEXT: ret i1 [[C2]]
32 %c1 = icmp ugt i32 %n, 10
33 %s = select i1 %c1, i32 %n, i32 10
34 %c2 = icmp ugt i32 %s, 11
38 define i1 @test_umin1(i32 %n) {
39 ; CHECK-LABEL: @test_umin1(
40 ; CHECK-NEXT: ret i1 true
42 %c1 = icmp ult i32 %n, 10
43 %s = select i1 %c1, i32 %n, i32 10
44 %c2 = icmp ult i32 %s, 11
48 define i1 @test_umin2(i32 %n) {
49 ; CHECK-LABEL: @test_umin2(
50 ; CHECK-NEXT: [[C1:%.*]] = icmp ult i32 [[N:%.*]], 10
51 ; CHECK-NEXT: ret i1 [[C1]]
53 %c1 = icmp ult i32 %n, 10
54 %s = select i1 %c1, i32 %n, i32 10
55 %c2 = icmp ult i32 %s, 10
59 define i1 @test_umin3(i32 %n) {
60 ; CHECK-LABEL: @test_umin3(
61 ; CHECK-NEXT: [[C1:%.*]] = icmp ult i32 [[N:%.*]], 10
62 ; CHECK-NEXT: [[S:%.*]] = select i1 [[C1]], i32 [[N]], i32 10
63 ; CHECK-NEXT: [[C2:%.*]] = icmp ult i32 [[S]], 9
64 ; CHECK-NEXT: ret i1 [[C2]]
66 %c1 = icmp ult i32 %n, 10
67 %s = select i1 %c1, i32 %n, i32 10
68 %c2 = icmp ult i32 %s, 9
72 define i1 @test_smax1(i32 %n) {
73 ; CHECK-LABEL: @test_smax1(
74 ; CHECK-NEXT: ret i1 true
76 %c1 = icmp sgt i32 %n, -10
77 %s = select i1 %c1, i32 %n, i32 -10
78 %c2 = icmp sgt i32 %s, -11
82 define i1 @test_smax2(i32 %n) {
83 ; CHECK-LABEL: @test_smax2(
84 ; CHECK-NEXT: [[C1:%.*]] = icmp sgt i32 [[N:%.*]], -10
85 ; CHECK-NEXT: ret i1 [[C1]]
87 %c1 = icmp sgt i32 %n, -10
88 %s = select i1 %c1, i32 %n, i32 -10
89 %c2 = icmp sgt i32 %s, -10
93 define i1 @test_smax3(i32 %n) {
94 ; CHECK-LABEL: @test_smax3(
95 ; CHECK-NEXT: [[C1:%.*]] = icmp sgt i32 [[N:%.*]], -10
96 ; CHECK-NEXT: [[S:%.*]] = select i1 [[C1]], i32 [[N]], i32 -10
97 ; CHECK-NEXT: [[C2:%.*]] = icmp sgt i32 [[S]], -9
98 ; CHECK-NEXT: ret i1 [[C2]]
100 %c1 = icmp sgt i32 %n, -10
101 %s = select i1 %c1, i32 %n, i32 -10
102 %c2 = icmp sgt i32 %s, -9
106 define i1 @test_smin1(i32 %n) {
107 ; CHECK-LABEL: @test_smin1(
108 ; CHECK-NEXT: ret i1 true
110 %c1 = icmp slt i32 %n, 10
111 %s = select i1 %c1, i32 %n, i32 10
112 %c2 = icmp slt i32 %s, 11
116 define i1 @test_smin2(i32 %n) {
117 ; CHECK-LABEL: @test_smin2(
118 ; CHECK-NEXT: [[C1:%.*]] = icmp slt i32 [[N:%.*]], 10
119 ; CHECK-NEXT: ret i1 [[C1]]
121 %c1 = icmp slt i32 %n, 10
122 %s = select i1 %c1, i32 %n, i32 10
123 %c2 = icmp slt i32 %s, 10
127 define i1 @test_smin3(i32 %n) {
128 ; CHECK-LABEL: @test_smin3(
129 ; CHECK-NEXT: [[C1:%.*]] = icmp slt i32 [[N:%.*]], 10
130 ; CHECK-NEXT: [[S:%.*]] = select i1 [[C1]], i32 [[N]], i32 10
131 ; CHECK-NEXT: [[C2:%.*]] = icmp slt i32 [[S]], 9
132 ; CHECK-NEXT: ret i1 [[C2]]
134 %c1 = icmp slt i32 %n, 10
135 %s = select i1 %c1, i32 %n, i32 10
136 %c2 = icmp slt i32 %s, 9