Sanjay Patel | 5865d12 | 2016-12-31 19:23:26 +0000 | [diff] [blame^] | 1 | ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py |
| 2 | ; RUN: opt -S -instsimplify < %s | FileCheck %s |
| 3 | |
| 4 | declare void @bar(i8* %a, i8* nonnull %b) |
| 5 | |
| 6 | ; 'y' must be nonnull. |
| 7 | |
| 8 | define i1 @caller1(i8* %x, i8* %y) { |
| 9 | ; CHECK-LABEL: @caller1( |
| 10 | ; CHECK-NEXT: call void @bar(i8* %x, i8* %y) |
| 11 | ; CHECK-NEXT: [[NULL_CHECK:%.*]] = icmp eq i8* %y, null |
| 12 | ; CHECK-NEXT: ret i1 [[NULL_CHECK]] |
| 13 | ; |
| 14 | call void @bar(i8* %x, i8* %y) |
| 15 | %null_check = icmp eq i8* %y, null |
| 16 | ret i1 %null_check |
| 17 | } |
| 18 | |
| 19 | ; Don't know anything about 'y'. |
| 20 | |
| 21 | define i1 @caller2(i8* %x, i8* %y) { |
| 22 | ; CHECK-LABEL: @caller2( |
| 23 | ; CHECK-NEXT: call void @bar(i8* %y, i8* %x) |
| 24 | ; CHECK-NEXT: [[NULL_CHECK:%.*]] = icmp eq i8* %y, null |
| 25 | ; CHECK-NEXT: ret i1 [[NULL_CHECK]] |
| 26 | ; |
| 27 | call void @bar(i8* %y, i8* %x) |
| 28 | %null_check = icmp eq i8* %y, null |
| 29 | ret i1 %null_check |
| 30 | } |
| 31 | |
| 32 | ; 'y' must be nonnull. |
| 33 | |
| 34 | define i1 @caller3(i8* %x, i8* %y) { |
| 35 | ; CHECK-LABEL: @caller3( |
| 36 | ; CHECK-NEXT: call void @bar(i8* %x, i8* %y) |
| 37 | ; CHECK-NEXT: [[NULL_CHECK:%.*]] = icmp ne i8* %y, null |
| 38 | ; CHECK-NEXT: ret i1 [[NULL_CHECK]] |
| 39 | ; |
| 40 | call void @bar(i8* %x, i8* %y) |
| 41 | %null_check = icmp ne i8* %y, null |
| 42 | ret i1 %null_check |
| 43 | } |
| 44 | |
| 45 | ; Don't know anything about 'y'. |
| 46 | |
| 47 | define i1 @caller4(i8* %x, i8* %y) { |
| 48 | ; CHECK-LABEL: @caller4( |
| 49 | ; CHECK-NEXT: call void @bar(i8* %y, i8* %x) |
| 50 | ; CHECK-NEXT: [[NULL_CHECK:%.*]] = icmp ne i8* %y, null |
| 51 | ; CHECK-NEXT: ret i1 [[NULL_CHECK]] |
| 52 | ; |
| 53 | call void @bar(i8* %y, i8* %x) |
| 54 | %null_check = icmp ne i8* %y, null |
| 55 | ret i1 %null_check |
| 56 | } |
| 57 | |