64 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py2; RUN: opt -S -mtriple=amdgcn-amd-amdhsa -passes=amdgpu-promote-alloca -disable-promote-alloca-to-lds=1 < %s | FileCheck %s3 4; Check that the extracted index is correctly sign-extended when 32-bit scratch5; address arithmetic is promoted to 64-bit vector index arithmetic.6 7define amdgpu_kernel void @negative_index_byte(ptr %out, i64 %offset) {8; CHECK-LABEL: @negative_index_byte(9; CHECK-NEXT: [[STACK:%.*]] = freeze <4 x i8> poison10; CHECK-NEXT: [[TMP1:%.*]] = insertelement <4 x i8> [[STACK]], i8 0, i32 011; CHECK-NEXT: [[TMP2:%.*]] = insertelement <4 x i8> [[TMP1]], i8 1, i32 112; CHECK-NEXT: [[TMP3:%.*]] = insertelement <4 x i8> [[TMP2]], i8 2, i32 213; CHECK-NEXT: [[TMP4:%.*]] = insertelement <4 x i8> [[TMP3]], i8 3, i32 314; CHECK-NEXT: [[TMP5:%.*]] = add i64 [[OFFSET:%.*]], -115; CHECK-NEXT: [[TMP6:%.*]] = extractelement <4 x i8> [[TMP4]], i64 [[TMP5]]16; CHECK-NEXT: store i8 [[TMP6]], ptr [[OUT:%.*]], align 117; CHECK-NEXT: ret void18;19 %stack = alloca [4 x i8], align 4, addrspace(5)20 %gep.0 = getelementptr inbounds [4 x i8], ptr addrspace(5) %stack, i64 0, i64 021 %gep.1 = getelementptr inbounds [4 x i8], ptr addrspace(5) %stack, i64 0, i64 122 %gep.2 = getelementptr inbounds [4 x i8], ptr addrspace(5) %stack, i64 0, i64 223 %gep.3 = getelementptr inbounds [4 x i8], ptr addrspace(5) %stack, i64 0, i64 324 store i8 0, ptr addrspace(5) %gep.025 store i8 1, ptr addrspace(5) %gep.126 store i8 2, ptr addrspace(5) %gep.227 store i8 3, ptr addrspace(5) %gep.328 %vgep = getelementptr inbounds [4 x i8], ptr addrspace(5) %stack, i64 0, i64 %offset29 %cgep = getelementptr inbounds [4 x i8], ptr addrspace(5) %vgep, i64 0, i64 -130 %load = load i8, ptr addrspace(5) %cgep31 store i8 %load, ptr %out32 ret void33}34 35define amdgpu_kernel void @negative_index_word(ptr %out, i64 %offset) {36; CHECK-LABEL: @negative_index_word(37; CHECK-NEXT: [[STACK:%.*]] = freeze <4 x i32> poison38; CHECK-NEXT: [[TMP1:%.*]] = insertelement <4 x i32> [[STACK]], i32 0, i32 039; CHECK-NEXT: [[TMP2:%.*]] = insertelement <4 x i32> [[TMP1]], i32 1, i32 140; CHECK-NEXT: [[TMP3:%.*]] = insertelement <4 x i32> [[TMP2]], i32 2, i32 241; CHECK-NEXT: [[TMP4:%.*]] = insertelement <4 x i32> [[TMP3]], i32 3, i32 342; CHECK-NEXT: [[TMP5:%.*]] = add i64 [[OFFSET:%.*]], -143; CHECK-NEXT: [[TMP6:%.*]] = extractelement <4 x i32> [[TMP4]], i64 [[TMP5]]44; CHECK-NEXT: store i32 [[TMP6]], ptr [[OUT:%.*]], align 445; CHECK-NEXT: ret void46;47 %stack = alloca [4 x i32], align 4, addrspace(5)48 %gep.0 = getelementptr inbounds [4 x i32], ptr addrspace(5) %stack, i64 0, i64 049 %gep.1 = getelementptr inbounds [4 x i32], ptr addrspace(5) %stack, i64 0, i64 150 %gep.2 = getelementptr inbounds [4 x i32], ptr addrspace(5) %stack, i64 0, i64 251 %gep.3 = getelementptr inbounds [4 x i32], ptr addrspace(5) %stack, i64 0, i64 352 store i32 0, ptr addrspace(5) %gep.053 store i32 1, ptr addrspace(5) %gep.154 store i32 2, ptr addrspace(5) %gep.255 store i32 3, ptr addrspace(5) %gep.356 %vgep = getelementptr inbounds [4 x i32], ptr addrspace(5) %stack, i64 0, i64 %offset57 %cgep = getelementptr inbounds [4 x i32], ptr addrspace(5) %vgep, i64 0, i64 -158 %load = load i32, ptr addrspace(5) %cgep59 store i32 %load, ptr %out60 ret void61}62 63 64