1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -passes=instsimplify < %s -S | FileCheck %s
4 define i1 @phi_ugt_non_zero(i8 %x) {
5 ; CHECK-LABEL: @phi_ugt_non_zero(
7 ; CHECK-NEXT: [[CMP:%.*]] = icmp ugt i8 [[X:%.*]], 32
8 ; CHECK-NEXT: br i1 [[CMP]], label [[T:%.*]], label [[F:%.*]]
10 ; CHECK-NEXT: ret i1 false
12 ; CHECK-NEXT: br label [[T]]
15 %cmp = icmp ugt i8 %x, 32
16 br i1 %cmp, label %T, label %F
18 %v = phi i8 [ %x, %entry], [-1, %F]
25 define i1 @phi_uge_non_zero(i8 %x) {
26 ; CHECK-LABEL: @phi_uge_non_zero(
28 ; CHECK-NEXT: [[CMP:%.*]] = icmp uge i8 [[X:%.*]], 32
29 ; CHECK-NEXT: br i1 [[CMP]], label [[T:%.*]], label [[F:%.*]]
31 ; CHECK-NEXT: ret i1 false
33 ; CHECK-NEXT: br label [[T]]
36 %cmp = icmp uge i8 %x, 32
37 br i1 %cmp, label %T, label %F
39 %v = phi i8 [ %x, %entry], [-1, %F]
46 define i1 @phi_ugt_non_zero_fail(i8 %x) {
47 ; CHECK-LABEL: @phi_ugt_non_zero_fail(
49 ; CHECK-NEXT: [[CMP:%.*]] = icmp ugt i8 [[X:%.*]], 32
50 ; CHECK-NEXT: br i1 [[CMP]], label [[T:%.*]], label [[F:%.*]]
52 ; CHECK-NEXT: [[V:%.*]] = phi i8 [ [[X]], [[ENTRY:%.*]] ], [ 0, [[F]] ]
53 ; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[V]], 0
54 ; CHECK-NEXT: ret i1 [[R]]
56 ; CHECK-NEXT: br label [[T]]
59 %cmp = icmp ugt i8 %x, 32
60 br i1 %cmp, label %T, label %F
62 %v = phi i8 [ %x, %entry], [0, %F]
69 define i1 @phi_ult_non_zero(i8 %x) {
70 ; CHECK-LABEL: @phi_ult_non_zero(
72 ; CHECK-NEXT: [[CMP:%.*]] = icmp ult i8 [[X:%.*]], 123
73 ; CHECK-NEXT: br i1 [[CMP]], label [[T:%.*]], label [[F:%.*]]
75 ; CHECK-NEXT: br label [[F]]
77 ; CHECK-NEXT: ret i1 false
80 %cmp = icmp ult i8 %x, 123
81 br i1 %cmp, label %T, label %F
85 %v = phi i8 [ %x, %entry], [-1, %T]
90 define i1 @phi_ule_non_zero(i8 %x) {
91 ; CHECK-LABEL: @phi_ule_non_zero(
93 ; CHECK-NEXT: [[CMP:%.*]] = icmp ule i8 [[X:%.*]], 123
94 ; CHECK-NEXT: br i1 [[CMP]], label [[T:%.*]], label [[F:%.*]]
96 ; CHECK-NEXT: br label [[F]]
98 ; CHECK-NEXT: ret i1 false
101 %cmp = icmp ule i8 %x, 123
102 br i1 %cmp, label %T, label %F
106 %v = phi i8 [ %x, %entry], [-1, %T]
107 %r = icmp eq i8 %v, 0
111 define i1 @phi_ule_non_zero_fail_wrong_succ(i8 %x) {
112 ; CHECK-LABEL: @phi_ule_non_zero_fail_wrong_succ(
114 ; CHECK-NEXT: [[CMP:%.*]] = icmp ule i8 [[X:%.*]], 123
115 ; CHECK-NEXT: br i1 [[CMP]], label [[T:%.*]], label [[F:%.*]]
117 ; CHECK-NEXT: [[V:%.*]] = phi i8 [ [[X]], [[ENTRY:%.*]] ], [ -1, [[F]] ]
118 ; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[V]], 0
119 ; CHECK-NEXT: ret i1 [[R]]
121 ; CHECK-NEXT: br label [[T]]
124 %cmp = icmp ule i8 %x, 123
125 br i1 %cmp, label %T, label %F
127 %v = phi i8 [ %x, %entry], [-1, %F]
128 %r = icmp eq i8 %v, 0
134 define i1 @phi_ult_non_zero_fail(i8 %x) {
135 ; CHECK-LABEL: @phi_ult_non_zero_fail(
137 ; CHECK-NEXT: [[CMP:%.*]] = icmp ult i8 [[X:%.*]], 123
138 ; CHECK-NEXT: [[X2:%.*]] = add i8 [[X]], [[X]]
139 ; CHECK-NEXT: br i1 [[CMP]], label [[T:%.*]], label [[F:%.*]]
141 ; CHECK-NEXT: br label [[F]]
143 ; CHECK-NEXT: [[V:%.*]] = phi i8 [ [[X2]], [[ENTRY:%.*]] ], [ -1, [[T]] ]
144 ; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[V]], 0
145 ; CHECK-NEXT: ret i1 [[R]]
148 %cmp = icmp ult i8 %x, 123
150 br i1 %cmp, label %T, label %F
154 %v = phi i8 [ %x2, %entry], [-1, %T]
155 %r = icmp eq i8 %v, 0
159 define i1 @phi_ne_non_zero(i8 %x) {
160 ; CHECK-LABEL: @phi_ne_non_zero(
162 ; CHECK-NEXT: [[CMP:%.*]] = icmp ne i8 [[X:%.*]], 0
163 ; CHECK-NEXT: br i1 [[CMP]], label [[T:%.*]], label [[F:%.*]]
165 ; CHECK-NEXT: ret i1 false
167 ; CHECK-NEXT: br label [[T]]
170 %cmp = icmp ne i8 %x, 0
171 br i1 %cmp, label %T, label %F
173 %v = phi i8 [ %x, %entry], [-1, %F]
174 %r = icmp eq i8 %v, 0
180 define i1 @phi_eq_non_zero(i8 %x) {
181 ; CHECK-LABEL: @phi_eq_non_zero(
183 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i8 [[X:%.*]], 44
184 ; CHECK-NEXT: br i1 [[CMP]], label [[T:%.*]], label [[F:%.*]]
186 ; CHECK-NEXT: ret i1 false
188 ; CHECK-NEXT: br label [[T]]
191 %cmp = icmp eq i8 %x, 44
192 br i1 %cmp, label %T, label %F
194 %v = phi i8 [ %x, %entry], [-1, %F]
195 %r = icmp eq i8 %v, 0
201 define i1 @phi_eq_non_zero2(i8 %x) {
202 ; CHECK-LABEL: @phi_eq_non_zero2(
204 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i8 [[X:%.*]], 0
205 ; CHECK-NEXT: br i1 [[CMP]], label [[T:%.*]], label [[F:%.*]]
207 ; CHECK-NEXT: br label [[F]]
209 ; CHECK-NEXT: ret i1 false
212 %cmp = icmp eq i8 %x, 0
213 br i1 %cmp, label %T, label %F
217 %v = phi i8 [ %x, %entry], [-1, %T]
218 %r = icmp eq i8 %v, 0
222 define i1 @phi_sgt_non_zero(i8 %x) {
223 ; CHECK-LABEL: @phi_sgt_non_zero(
225 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i8 [[X:%.*]], 1
226 ; CHECK-NEXT: br i1 [[CMP]], label [[T:%.*]], label [[F:%.*]]
228 ; CHECK-NEXT: ret i1 false
230 ; CHECK-NEXT: br label [[T]]
233 %cmp = icmp sgt i8 %x, 1
234 br i1 %cmp, label %T, label %F
236 %v = phi i8 [ %x, %entry], [-1, %F]
237 %r = icmp eq i8 %v, 0
243 define i1 @phi_sgt_non_zero_fail(i8 %x) {
244 ; CHECK-LABEL: @phi_sgt_non_zero_fail(
246 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i8 [[X:%.*]], -1
247 ; CHECK-NEXT: br i1 [[CMP]], label [[T:%.*]], label [[F:%.*]]
249 ; CHECK-NEXT: [[V:%.*]] = phi i8 [ [[X]], [[ENTRY:%.*]] ], [ -1, [[F]] ]
250 ; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[V]], 0
251 ; CHECK-NEXT: ret i1 [[R]]
253 ; CHECK-NEXT: br label [[T]]
256 %cmp = icmp sgt i8 %x, -1
257 br i1 %cmp, label %T, label %F
259 %v = phi i8 [ %x, %entry], [-1, %F]
260 %r = icmp eq i8 %v, 0