1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 2; RUN: opt -S -mtriple=amdgcn-amd-amdhsa -infer-address-spaces %s | FileCheck %s 3 4; Addrspacecasts must be inserted after the instructions that define their uses. 5 6%struct.s0 = type { i32*, i32 } 7%struct.s1 = type { %struct.s0 } 8 9@global0 = protected addrspace(4) externally_initialized global %struct.s1 zeroinitializer 10 11declare i32 @func(i32* %arg) 12 13define i32 @insert_pos_assert() { 14; CHECK-LABEL: @insert_pos_assert( 15; CHECK-NEXT: [[ALLOCA:%.*]] = alloca i32, align 4, addrspace(5) 16; CHECK-NEXT: [[LOAD0:%.*]] = load i32*, i32* addrspace(4)* getelementptr inbounds ([[STRUCT_S1:%.*]], [[STRUCT_S1]] addrspace(4)* @global0, i32 0, i32 0, i32 0), align 8 17; CHECK-NEXT: [[TMP1:%.*]] = addrspacecast i32* [[LOAD0]] to i32 addrspace(1)* 18; CHECK-NEXT: [[TMP2:%.*]] = addrspacecast i32 addrspace(1)* [[TMP1]] to i32* 19; CHECK-NEXT: [[LOAD1:%.*]] = load i32, i32 addrspace(5)* [[ALLOCA]], align 4 20; CHECK-NEXT: [[SEXT:%.*]] = sext i32 [[LOAD1]] to i64 21; CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds i32, i32* [[TMP2]], i64 [[SEXT]] 22; CHECK-NEXT: [[CALL:%.*]] = call i32 @func(i32* [[GEP]]) 23; CHECK-NEXT: ret i32 [[CALL]] 24; 25 %alloca = alloca i32, align 4, addrspace(5) 26 %cast = addrspacecast i32 addrspace(5)* %alloca to i32* 27 %load0 = load i32*, i32* addrspace(4)* getelementptr inbounds (%struct.s1, %struct.s1 addrspace(4)* @global0, i32 0, i32 0, i32 0) 28 %load1 = load i32, i32* %cast 29 %sext = sext i32 %load1 to i64 30 %gep = getelementptr inbounds i32, i32* %load0, i64 %sext 31 %call = call i32 @func(i32* %gep) 32 ret i32 %call 33} 34