llvm.org GIT mirror llvm / 258eac5
[InstSimplify] add tests for icmp fold bug (PR39510); NFC Verify that set intersection/subset are not confused. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@345831 91177308-0d34-0410-b5e6-96231b3b80d8 Sanjay Patel 11 months ago
1 changed file(s) with 35 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
398398 ret <3 x i1> %r
399399 }
400400
401 ; Negative test - intersection does not equal absolute value range.
402 ; PR39510 - https://bugs.llvm.org/show_bug.cgi?id=39510
403
404 define i1 @abs_no_intersection(i32 %a) {
405 ; CHECK-LABEL: @abs_no_intersection(
406 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[A:%.*]], 0
407 ; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[A]]
408 ; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[SUB]], i32 [[A]]
409 ; CHECK-NEXT: [[R:%.*]] = icmp ne i32 [[COND]], 2
410 ; CHECK-NEXT: ret i1 [[R]]
411 ;
412 %cmp = icmp slt i32 %a, 0
413 %sub = sub nsw i32 0, %a
414 %cond = select i1 %cmp, i32 %sub, i32 %a
415 %r = icmp ne i32 %cond, 2
416 ret i1 %r
417 }
418
419 ; Negative test - intersection does not equal absolute value range.
420
421 define i1 @nabs_no_intersection(i32 %a) {
422 ; CHECK-LABEL: @nabs_no_intersection(
423 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 [[A:%.*]], 0
424 ; CHECK-NEXT: [[SUB:%.*]] = sub i32 0, [[A]]
425 ; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[SUB]], i32 [[A]]
426 ; CHECK-NEXT: [[R:%.*]] = icmp ne i32 [[COND]], -2
427 ; CHECK-NEXT: ret i1 [[R]]
428 ;
429 %cmp = icmp sgt i32 %a, 0
430 %sub = sub i32 0, %a
431 %cond = select i1 %cmp, i32 %sub, i32 %a
432 %r = icmp ne i32 %cond, -2
433 ret i1 %r
434 }
435