1; RUN: opt -basic-aa -loop-idiom -S < %s -march=r600 -mcpu=redwood | FileCheck --check-prefix=R600 --check-prefix=FUNC %s 2; RUN: opt -basic-aa -loop-idiom -S < %s -march=amdgcn -mcpu=tahiti -verify-machineinstrs| FileCheck --check-prefix=SI --check-prefix=FUNC %s 3; RUN: opt -basic-aa -loop-idiom -S < %s -march=amdgcn -mcpu=tonga -verify-machineinstrs| FileCheck --check-prefix=SI --check-prefix=FUNC %s 4 5target datalayout = "e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5" 6 7; Make sure loop-idiom doesn't create memcpy or memset. There are no library 8; implementations of these for R600. 9 10; FUNC: @no_memcpy 11; R600-NOT: {{^}}llvm.memcpy 12; SI-NOT: {{^}}llvm.memcpy 13define amdgpu_kernel void @no_memcpy(i8 addrspace(3)* %in, i32 %size) { 14entry: 15 %dest = alloca i8, i32 32, addrspace(5) 16 br label %for.body 17 18for.body: 19 %0 = phi i32 [0, %entry], [%4, %for.body] 20 %1 = getelementptr i8, i8 addrspace(3)* %in, i32 %0 21 %2 = getelementptr i8, i8 addrspace(5)* %dest, i32 %0 22 %3 = load i8, i8 addrspace(3)* %1 23 store i8 %3, i8 addrspace(5)* %2 24 %4 = add i32 %0, 1 25 %5 = icmp eq i32 %4, %size 26 br i1 %5, label %for.end, label %for.body 27 28for.end: 29 ret void 30} 31 32; FUNC: @no_memset 33; R600-NOT: {{^}}llvm.memset 34; R600-NOT: {{^}}memset_pattern16: 35; SI-NOT: {{^}}llvm.memset 36; SI-NOT: {{^}}memset_pattern16: 37define amdgpu_kernel void @no_memset(i32 %size) { 38entry: 39 %dest = alloca i8, i32 32, addrspace(5) 40 br label %for.body 41 42for.body: 43 %0 = phi i32 [0, %entry], [%2, %for.body] 44 %1 = getelementptr i8, i8 addrspace(5)* %dest, i32 %0 45 store i8 0, i8 addrspace(5)* %1 46 %2 = add i32 %0, 1 47 %3 = icmp eq i32 %2, %size 48 br i1 %3, label %for.end, label %for.body 49 50for.end: 51 ret void 52} 53