Yaxun Liu | 02f75f3 | 2016-11-21 15:42:31 +0000 | [diff] [blame] | 1 | ; RUN: opt -instcombine -S < %s | FileCheck %s |
| 2 | |
| 3 | ; When a pointer is addrspacecasted to a another addr space, we cannot assume |
| 4 | ; anything about the new bits. |
| 5 | |
| 6 | target datalayout = "p:32:32-p3:32:32-p4:64:64" |
| 7 | |
| 8 | ; CHECK-LABEL: @test_shift |
| 9 | ; CHECK-NOT: ret i64 0 |
| 10 | define i64 @test_shift(i8* %p) { |
| 11 | %g = addrspacecast i8* %p to i8 addrspace(4)* |
| 12 | %i = ptrtoint i8 addrspace(4)* %g to i64 |
| 13 | %shift = lshr i64 %i, 32 |
| 14 | ret i64 %shift |
| 15 | } |
| 16 | |
| 17 | ; CHECK-LABEL: @test_null |
| 18 | ; A null pointer casted to another addr space may no longer have null value. |
| 19 | ; CHECK-NOT: ret i32 0 |
| 20 | define i32 @test_null() { |
| 21 | %g = addrspacecast i8* null to i8 addrspace(3)* |
| 22 | %i = ptrtoint i8 addrspace(3)* %g to i32 |
| 23 | ret i32 %i |
| 24 | } |