llvm.org GIT mirror llvm / 9abf4ae
[InstSimplify] add tests for fcmp folds; NFC This is part of a problem noted in PR39475: https://bugs.llvm.org/show_bug.cgi?id=39475 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@345615 91177308-0d34-0410-b5e6-96231b3b80d8 Sanjay Patel 11 months ago
1 changed file(s) with 73 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
233233 ret i1 %olt
234234 }
235235
236 define i1 @orderedLessZeroUIToFP(i32) {
236 define i1 @orderedLessZeroUIToFP(i32 %x) {
237237 ; CHECK-LABEL: @orderedLessZeroUIToFP(
238238 ; CHECK-NEXT: ret i1 true
239239 ;
240 %a = uitofp i32 %0 to float
240 %a = uitofp i32 %x to float
241241 %uge = fcmp uge float %a, 0.000000e+00
242242 ret i1 %uge
243 }
244
245 define <2 x i1> @orderedLessZeroUIToFP_vec(<2 x i32> %x) {
246 ; CHECK-LABEL: @orderedLessZeroUIToFP_vec(
247 ; CHECK-NEXT: ret <2 x i1>
248 ;
249 %a = uitofp <2 x i32> %x to <2 x float>
250 %uge = fcmp uge <2 x float> %a, zeroinitializer
251 ret <2 x i1> %uge
252 }
253
254 define i1 @orderedLessZeroUIToFP_nnan(i32 %x) {
255 ; CHECK-LABEL: @orderedLessZeroUIToFP_nnan(
256 ; CHECK-NEXT: [[A:%.*]] = uitofp i32 [[X:%.*]] to float
257 ; CHECK-NEXT: [[UGE:%.*]] = fcmp nnan oge float [[A]], 0.000000e+00
258 ; CHECK-NEXT: ret i1 [[UGE]]
259 ;
260 %a = uitofp i32 %x to float
261 %uge = fcmp nnan oge float %a, 0.000000e+00
262 ret i1 %uge
263 }
264
265 define <2 x i1> @orderedLessZeroUIToFP_nnan_vec(<2 x i32> %x) {
266 ; CHECK-LABEL: @orderedLessZeroUIToFP_nnan_vec(
267 ; CHECK-NEXT: [[A:%.*]] = uitofp <2 x i32> [[X:%.*]] to <2 x float>
268 ; CHECK-NEXT: [[UGE:%.*]] = fcmp nnan oge <2 x float> [[A]], zeroinitializer
269 ; CHECK-NEXT: ret <2 x i1> [[UGE]]
270 ;
271 %a = uitofp <2 x i32> %x to <2 x float>
272 %uge = fcmp nnan oge <2 x float> %a, zeroinitializer
273 ret <2 x i1> %uge
274 }
275
276 define i1 @fabs_is_nan_or_positive_or_zero(double %x) {
277 ; CHECK-LABEL: @fabs_is_nan_or_positive_or_zero(
278 ; CHECK-NEXT: ret i1 true
279 ;
280 %fabs = tail call double @llvm.fabs.f64(double %x)
281 %cmp = fcmp uge double %fabs, 0.0
282 ret i1 %cmp
283 }
284
285 define <2 x i1> @fabs_is_nan_or_positive_or_zero_vec(<2 x double> %x) {
286 ; CHECK-LABEL: @fabs_is_nan_or_positive_or_zero_vec(
287 ; CHECK-NEXT: ret <2 x i1>
288 ;
289 %fabs = tail call <2 x double> @llvm.fabs.v2f64(<2 x double> %x)
290 %cmp = fcmp uge <2 x double> %fabs, zeroinitializer
291 ret <2 x i1> %cmp
292 }
293
294 define i1 @fabs_nnan_is_positive_or_zero(double %x) {
295 ; CHECK-LABEL: @fabs_nnan_is_positive_or_zero(
296 ; CHECK-NEXT: [[FABS:%.*]] = tail call double @llvm.fabs.f64(double [[X:%.*]])
297 ; CHECK-NEXT: [[CMP:%.*]] = fcmp nnan oge double [[FABS]], 0.000000e+00
298 ; CHECK-NEXT: ret i1 [[CMP]]
299 ;
300 %fabs = tail call double @llvm.fabs.f64(double %x)
301 %cmp = fcmp nnan oge double %fabs, 0.0
302 ret i1 %cmp
303 }
304
305 define <2 x i1> @fabs_nnan_is_positive_or_zero_vec(<2 x double> %x) {
306 ; CHECK-LABEL: @fabs_nnan_is_positive_or_zero_vec(
307 ; CHECK-NEXT: [[FABS:%.*]] = tail call <2 x double> @llvm.fabs.v2f64(<2 x double> [[X:%.*]])
308 ; CHECK-NEXT: [[CMP:%.*]] = fcmp nnan oge <2 x double> [[FABS]], zeroinitializer
309 ; CHECK-NEXT: ret <2 x i1> [[CMP]]
310 ;
311 %fabs = tail call <2 x double> @llvm.fabs.v2f64(<2 x double> %x)
312 %cmp = fcmp nnan oge <2 x double> %fabs, zeroinitializer
313 ret <2 x i1> %cmp
243314 }
244315
245316 define i1 @orderedLessZeroSelect(float, float) {