1*9880d681SAndroid Build Coastguard Worker; RUN: opt -S -mtriple=amdgcn-amd-amdhsa -amdgpu-promote-alloca < %s | FileCheck %s 2*9880d681SAndroid Build Coastguard Worker 3*9880d681SAndroid Build Coastguard Worker; Make sure this allocates the correct size if the alloca has a non-0 4*9880d681SAndroid Build Coastguard Worker; number of elements. 5*9880d681SAndroid Build Coastguard Worker 6*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: @array_alloca( 7*9880d681SAndroid Build Coastguard Worker; CHECK: %stack = alloca i32, i32 5, align 4 8*9880d681SAndroid Build Coastguard Workerdefine void @array_alloca(i32 addrspace(1)* nocapture %out, i32 addrspace(1)* nocapture %in) #0 { 9*9880d681SAndroid Build Coastguard Workerentry: 10*9880d681SAndroid Build Coastguard Worker %stack = alloca i32, i32 5, align 4 11*9880d681SAndroid Build Coastguard Worker %ld0 = load i32, i32 addrspace(1)* %in, align 4 12*9880d681SAndroid Build Coastguard Worker %arrayidx1 = getelementptr inbounds i32, i32* %stack, i32 %ld0 13*9880d681SAndroid Build Coastguard Worker store i32 4, i32* %arrayidx1, align 4 14*9880d681SAndroid Build Coastguard Worker %arrayidx2 = getelementptr inbounds i32, i32 addrspace(1)* %in, i32 1 15*9880d681SAndroid Build Coastguard Worker %ld1 = load i32, i32 addrspace(1)* %arrayidx2, align 4 16*9880d681SAndroid Build Coastguard Worker %arrayidx3 = getelementptr inbounds i32, i32* %stack, i32 %ld1 17*9880d681SAndroid Build Coastguard Worker store i32 5, i32* %arrayidx3, align 4 18*9880d681SAndroid Build Coastguard Worker %arrayidx10 = getelementptr inbounds i32, i32* %stack, i32 0 19*9880d681SAndroid Build Coastguard Worker %ld2 = load i32, i32* %arrayidx10, align 4 20*9880d681SAndroid Build Coastguard Worker store i32 %ld2, i32 addrspace(1)* %out, align 4 21*9880d681SAndroid Build Coastguard Worker %arrayidx12 = getelementptr inbounds i32, i32* %stack, i32 1 22*9880d681SAndroid Build Coastguard Worker %ld3 = load i32, i32* %arrayidx12 23*9880d681SAndroid Build Coastguard Worker %arrayidx13 = getelementptr inbounds i32, i32 addrspace(1)* %out, i32 1 24*9880d681SAndroid Build Coastguard Worker store i32 %ld3, i32 addrspace(1)* %arrayidx13 25*9880d681SAndroid Build Coastguard Worker ret void 26*9880d681SAndroid Build Coastguard Worker} 27*9880d681SAndroid Build Coastguard Worker 28*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: @array_alloca_dynamic( 29*9880d681SAndroid Build Coastguard Worker; CHECK: %stack = alloca i32, i32 %size, align 4 30*9880d681SAndroid Build Coastguard Workerdefine void @array_alloca_dynamic(i32 addrspace(1)* nocapture %out, i32 addrspace(1)* nocapture %in, i32 %size) #0 { 31*9880d681SAndroid Build Coastguard Workerentry: 32*9880d681SAndroid Build Coastguard Worker %stack = alloca i32, i32 %size, align 4 33*9880d681SAndroid Build Coastguard Worker %ld0 = load i32, i32 addrspace(1)* %in, align 4 34*9880d681SAndroid Build Coastguard Worker %arrayidx1 = getelementptr inbounds i32, i32* %stack, i32 %ld0 35*9880d681SAndroid Build Coastguard Worker store i32 4, i32* %arrayidx1, align 4 36*9880d681SAndroid Build Coastguard Worker %arrayidx2 = getelementptr inbounds i32, i32 addrspace(1)* %in, i32 1 37*9880d681SAndroid Build Coastguard Worker %ld1 = load i32, i32 addrspace(1)* %arrayidx2, align 4 38*9880d681SAndroid Build Coastguard Worker %arrayidx3 = getelementptr inbounds i32, i32* %stack, i32 %ld1 39*9880d681SAndroid Build Coastguard Worker store i32 5, i32* %arrayidx3, align 4 40*9880d681SAndroid Build Coastguard Worker %arrayidx10 = getelementptr inbounds i32, i32* %stack, i32 0 41*9880d681SAndroid Build Coastguard Worker %ld2 = load i32, i32* %arrayidx10, align 4 42*9880d681SAndroid Build Coastguard Worker store i32 %ld2, i32 addrspace(1)* %out, align 4 43*9880d681SAndroid Build Coastguard Worker %arrayidx12 = getelementptr inbounds i32, i32* %stack, i32 1 44*9880d681SAndroid Build Coastguard Worker %ld3 = load i32, i32* %arrayidx12 45*9880d681SAndroid Build Coastguard Worker %arrayidx13 = getelementptr inbounds i32, i32 addrspace(1)* %out, i32 1 46*9880d681SAndroid Build Coastguard Worker store i32 %ld3, i32 addrspace(1)* %arrayidx13 47*9880d681SAndroid Build Coastguard Worker ret void 48*9880d681SAndroid Build Coastguard Worker} 49*9880d681SAndroid Build Coastguard Worker 50*9880d681SAndroid Build Coastguard Workerattributes #0 = { nounwind } 51