brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.7 KiB · 073aad8 Raw
48 lines · plain
1; RUN: opt -mtriple=amdgcn-- -O1 -S < %s | FileCheck %s --check-prefixes=FUNC,LOOP2; RUN: opt -mtriple=amdgcn-- -passes='default<O1>' -S < %s | FileCheck %s --check-prefixes=FUNC,LOOP3; RUN: opt -mtriple=amdgcn-- -O1 -S -disable-promote-alloca-to-vector < %s | FileCheck %s --check-prefixes=FUNC,FULL-UNROLL4; RUN: opt -mtriple=amdgcn-- -passes='default<O1>' -S -disable-promote-alloca-to-vector < %s | FileCheck %s --check-prefixes=FUNC,FULL-UNROLL5 6; This test contains a simple loop that initializes an array declared in7; private memory. This loop would be fully unrolled if we could not SROA8; the alloca. Check that we successfully eliminate it before the unroll,9; so that we do not need to fully unroll it.10 11; FUNC-LABEL: @private_memory12; LOOP-NOT: = alloca13; LOOP: loop.header:14; LOOP: br i1 %{{[^,]+}}, label %exit, label %loop.header15 16; FULL-UNROLL: alloca17; FULL-UNROLL-COUNT-256: store i32 {{[0-9]+}}, ptr addrspace(5)18; FULL-UNROLL-NOT: br19 20; FUNC: store i32 %{{[^,]+}}, ptr addrspace(1) %out21define amdgpu_kernel void @private_memory(ptr addrspace(1) %out, i32 %n) {22entry:23  %alloca = alloca [16 x i32], addrspace(5)24  br label %loop.header25 26loop.header:27  %counter = phi i32 [0, %entry], [%inc, %loop.inc]28  br label %loop.body29 30loop.body:31  %salt = xor i32 %counter, %n32  %idx = and i32 %salt, 1533  %ptr = getelementptr [16 x i32], ptr addrspace(5) %alloca, i32 0, i32 %idx34  store i32 %counter, ptr addrspace(5) %ptr35  br label %loop.inc36 37loop.inc:38  %inc = add i32 %counter, 139  %cmp = icmp sge i32 %counter, 25540  br i1 %cmp, label  %exit, label %loop.header41 42exit:43  %gep = getelementptr [16 x i32], ptr addrspace(5) %alloca, i32 0, i32 %n44  %load = load i32, ptr addrspace(5) %gep45  store i32 %load, ptr addrspace(1) %out46  ret void47}48