llvm.org GIT mirror llvm / c76b62e
[InstCombine] Add foldAndOfICmps test cases inspired by PR42691. icmp ne %x, INT_MIN can be treated similarly to icmp sgt %x, INT_MIN. icmp ne %x, INT_MAX can be treated similarly to icmp slt %x, INT_MAX. icmp ne %x, UINT_MAX can be treated similarly to icmp ult %x, UINT_MAX. We already treat icmp ne %x, 0 similarly to icmp ugt %x, 0 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@366662 91177308-0d34-0410-b5e6-96231b3b80d8 Craig Topper a month ago
1 changed file(s) with 39 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
337337 %c = or i1 %c1, %c2
338338 ret i1 %c
339339 }
340
341 define i1 @PR42691_8(i32 %x) {
342 ; CHECK-LABEL: @PR42691_8(
343 ; CHECK-NEXT: [[C1:%.*]] = icmp slt i32 %x, 14
344 ; CHECK-NEXT: [[C2:%.*]] = icmp ne i32 %x, -2147483648
345 ; CHECK-NEXT: [[C:%.*]] = and i1 [[C1]], [[C2]]
346 ; CHECK-NEXT: ret i1 [[C]]
347 ;
348 %c1 = icmp slt i32 %x, 14
349 %c2 = icmp ne i32 %x, -2147483648
350 %c = and i1 %c1, %c2
351 ret i1 %c
352 }
353
354 define i1 @PR42691_9(i32 %x) {
355 ; CHECK-LABEL: @PR42691_9(
356 ; CHECK-NEXT: [[C1:%.*]] = icmp sgt i32 %x, 13
357 ; CHECK-NEXT: [[C2:%.*]] = icmp ne i32 %x, 2147483647
358 ; CHECK-NEXT: [[C:%.*]] = and i1 [[C1]], [[C2]]
359 ; CHECK-NEXT: ret i1 [[C]]
360 ;
361 %c1 = icmp sgt i32 %x, 13
362 %c2 = icmp ne i32 %x, 2147483647
363 %c = and i1 %c1, %c2
364 ret i1 %c
365 }
366
367 define i1 @PR42691_10(i32 %x) {
368 ; CHECK-LABEL: @PR42691_10(
369 ; CHECK-NEXT: [[C1:%.*]] = icmp ugt i32 %x, 13
370 ; CHECK-NEXT: [[C2:%.*]] = icmp ne i32 %x, -1
371 ; CHECK-NEXT: [[C:%.*]] = and i1 [[C1]], [[C2]]
372 ; CHECK-NEXT: ret i1 [[C]]
373 ;
374 %c1 = icmp ugt i32 %x, 13
375 %c2 = icmp ne i32 %x, 4294967295
376 %c = and i1 %c1, %c2
377 ret i1 %c
378 }