50 lines · plain
1; RUN: opt -S -dxil-resource-access -mtriple=dxil %s | FileCheck %s2;3; Test for when we have indices into both the array and the vector: ie, s[1][3]4 5; cbuffer CB : register(b0) {6; uint4 s[3]; // offset 0, size 16 * 37; }8%__cblayout_CB = type <{ [2 x <4 x i32>] }>9 10@CB.cb = local_unnamed_addr global target("dx.CBuffer", %__cblayout_CB) poison11 12; CHECK: define void @f13define void @f(ptr %dst) {14entry:15 %CB.cb_h = tail call target("dx.CBuffer", %__cblayout_CB) @llvm.dx.resource.handlefromimplicitbinding(i32 1, i32 0, i32 1, i32 0, ptr null)16 store target("dx.CBuffer", %__cblayout_CB) %CB.cb_h, ptr @CB.cb, align 417 18 ; CHECK: [[CB:%.*]] = load target("dx.CBuffer", %__cblayout_CB), ptr @CB.cb19 %CB.cb = load target("dx.CBuffer", %__cblayout_CB), ptr @CB.cb, align 420 21 ;; s[1][3]22 ;23 ; CHECK: [[LOAD:%.*]] = call { i32, i32, i32, i32 } @llvm.dx.resource.load.cbufferrow.4.{{.*}}(target("dx.CBuffer", %__cblayout_CB) [[CB]], i32 1)24 ; CHECK: [[X:%.*]] = extractvalue { i32, i32, i32, i32 } [[LOAD]], 325 ; CHECK: store i32 [[X]], ptr %dst26 %i8_ptr = call ptr addrspace(2) @llvm.dx.resource.getpointer(target("dx.CBuffer", %__cblayout_CB) %CB.cb, i32 0)27 %i8_gep = getelementptr inbounds nuw i8, ptr addrspace(2) %i8_ptr, i32 2828 %i8_vecext = load i32, ptr addrspace(2) %i8_gep, align 429 store i32 %i8_vecext, ptr %dst, align 430 31 ;; s[2].w32 ;33 ; CHECK: [[LOAD:%.*]] = call { i32, i32, i32, i32 } @llvm.dx.resource.load.cbufferrow.4.{{.*}}(target("dx.CBuffer", %__cblayout_CB) [[CB]], i32 2)34 ; CHECK: [[X:%.*]] = extractvalue { i32, i32, i32, i32 } [[LOAD]], 335 ;;36 ;; It would be nice to avoid the redundant vector creation here, but that's37 ;; outside of the scope of this pass.38 ;;39 ; CHECK: [[X_VEC:%.*]] = insertelement <4 x i32> {{%.*}}, i32 [[X]], i32 340 ; CHECK: [[X_EXT:%.*]] = extractelement <4 x i32> [[X_VEC]], i32 341 ; CHECK: store i32 [[X_EXT]], ptr %dst42 %typed_ptr = call ptr addrspace(2) @llvm.dx.resource.getpointer(target("dx.CBuffer", %__cblayout_CB) %CB.cb, i32 0)43 %typed_gep = getelementptr <4 x i32>, ptr addrspace(2) %typed_ptr, i32 244 %typed_load = load <4 x i32>, ptr addrspace(2) %typed_gep, align 1645 %typed_vecext = extractelement <4 x i32> %typed_load, i32 346 store i32 %typed_vecext, ptr %dst, align 447 48 ret void49}50