1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -S -mtriple=amdgcn-amd-amdhsa -passes=infer-address-spaces -o - %s | FileCheck %s
3 ; https://github.com/llvm/llvm-project/issues/53665
5 define i32 @addrspacecast_ptrtoint_inttoptr(ptr addrspace(1) %arg) {
6 ; CHECK-LABEL: @addrspacecast_ptrtoint_inttoptr(
8 ; CHECK-NEXT: [[LOAD:%.*]] = load i32, ptr addrspace(1) [[ARG:%.*]], align 4
9 ; CHECK-NEXT: ret i32 [[LOAD]]
12 %asc = addrspacecast ptr addrspace(1) %arg to ptr
13 %p2i = ptrtoint ptr %asc to i64
14 %i2p = inttoptr i64 %p2i to ptr
15 %load = load i32, ptr %i2p
19 define i32 @assumed_ptrtoint_inttoptr(ptr %arg) {
21 %is.priv = call i1 @llvm.amdgcn.is.private(ptr %arg)
22 %not.is.priv = xor i1 %is.priv, -1
23 %is.shared = call i1 @llvm.amdgcn.is.shared(ptr %arg)
24 %not.is.shared = xor i1 %is.shared, -1
25 %and = and i1 %not.is.priv, %not.is.shared
26 tail call void @llvm.assume(i1 %and)
27 %p2i = ptrtoint ptr %arg to i64
28 %i2p = inttoptr i64 %p2i to ptr
29 %load = load i32, ptr %i2p
33 define i32 @addrspacecast_ptrtoint_inttptr_nontrivial(ptr addrspace(3) %arg) {
34 ; CHECK-LABEL: @addrspacecast_ptrtoint_inttptr_nontrivial(
36 ; CHECK-NEXT: [[LOAD:%.*]] = load i32, ptr addrspace(3) [[ARG:%.*]], align 4
37 ; CHECK-NEXT: ret i32 [[LOAD]]
40 %asc = addrspacecast ptr addrspace(3) %arg to ptr
41 %p2i = ptrtoint ptr %asc to i64
42 %i2p = inttoptr i64 %p2i to ptr
43 %load = load i32, ptr %i2p
47 declare void @llvm.assume(i1 noundef) #0
48 declare i1 @llvm.amdgcn.is.shared(ptr nocapture) #1
49 declare i1 @llvm.amdgcn.is.private(ptr nocapture) #1
51 attributes #0 = { inaccessiblememonly nofree nosync nounwind willreturn }
52 attributes #1 = { nounwind readnone speculatable willreturn }