xref: /aosp_15_r20/external/llvm/test/CodeGen/AMDGPU/loop-idiom.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: opt -basicaa -loop-idiom -S < %s -march=r600 -mcpu=redwood | FileCheck --check-prefix=R600 --check-prefix=FUNC %s
2*9880d681SAndroid Build Coastguard Worker; RUN: opt -basicaa -loop-idiom -S < %s -march=amdgcn -mcpu=SI -verify-machineinstrs| FileCheck --check-prefix=SI --check-prefix=FUNC %s
3*9880d681SAndroid Build Coastguard Worker; RUN: opt -basicaa -loop-idiom -S < %s -march=amdgcn -mcpu=tonga -verify-machineinstrs| FileCheck --check-prefix=SI --check-prefix=FUNC %s
4*9880d681SAndroid Build Coastguard Worker
5*9880d681SAndroid Build Coastguard Worker
6*9880d681SAndroid Build Coastguard Worker; Make sure loop-idiom doesn't create memcpy or memset.  There are no library
7*9880d681SAndroid Build Coastguard Worker; implementations of these for R600.
8*9880d681SAndroid Build Coastguard Worker
9*9880d681SAndroid Build Coastguard Worker; FUNC: @no_memcpy
10*9880d681SAndroid Build Coastguard Worker; R600-NOT: {{^}}llvm.memcpy
11*9880d681SAndroid Build Coastguard Worker; SI-NOT: {{^}}llvm.memcpy
12*9880d681SAndroid Build Coastguard Workerdefine void @no_memcpy(i8 addrspace(3)* %in, i32 %size) {
13*9880d681SAndroid Build Coastguard Workerentry:
14*9880d681SAndroid Build Coastguard Worker  %dest = alloca i8, i32 32
15*9880d681SAndroid Build Coastguard Worker  br label %for.body
16*9880d681SAndroid Build Coastguard Worker
17*9880d681SAndroid Build Coastguard Workerfor.body:
18*9880d681SAndroid Build Coastguard Worker  %0 = phi i32 [0, %entry], [%4, %for.body]
19*9880d681SAndroid Build Coastguard Worker  %1 = getelementptr i8, i8 addrspace(3)* %in, i32 %0
20*9880d681SAndroid Build Coastguard Worker  %2 = getelementptr i8, i8* %dest, i32 %0
21*9880d681SAndroid Build Coastguard Worker  %3 = load i8, i8 addrspace(3)* %1
22*9880d681SAndroid Build Coastguard Worker  store i8 %3, i8* %2
23*9880d681SAndroid Build Coastguard Worker  %4 = add i32 %0, 1
24*9880d681SAndroid Build Coastguard Worker  %5 = icmp eq i32 %4, %size
25*9880d681SAndroid Build Coastguard Worker  br i1 %5, label %for.end, label %for.body
26*9880d681SAndroid Build Coastguard Worker
27*9880d681SAndroid Build Coastguard Workerfor.end:
28*9880d681SAndroid Build Coastguard Worker  ret void
29*9880d681SAndroid Build Coastguard Worker}
30*9880d681SAndroid Build Coastguard Worker
31*9880d681SAndroid Build Coastguard Worker; FUNC: @no_memset
32*9880d681SAndroid Build Coastguard Worker; R600-NOT: {{^}}llvm.memset
33*9880d681SAndroid Build Coastguard Worker; R600-NOT: {{^}}memset_pattern16:
34*9880d681SAndroid Build Coastguard Worker; SI-NOT: {{^}}llvm.memset
35*9880d681SAndroid Build Coastguard Worker; SI-NOT: {{^}}memset_pattern16:
36*9880d681SAndroid Build Coastguard Workerdefine void @no_memset(i32 %size) {
37*9880d681SAndroid Build Coastguard Workerentry:
38*9880d681SAndroid Build Coastguard Worker  %dest = alloca i8, i32 32
39*9880d681SAndroid Build Coastguard Worker  br label %for.body
40*9880d681SAndroid Build Coastguard Worker
41*9880d681SAndroid Build Coastguard Workerfor.body:
42*9880d681SAndroid Build Coastguard Worker  %0 = phi i32 [0, %entry], [%2, %for.body]
43*9880d681SAndroid Build Coastguard Worker  %1 = getelementptr i8, i8* %dest, i32 %0
44*9880d681SAndroid Build Coastguard Worker  store i8 0, i8* %1
45*9880d681SAndroid Build Coastguard Worker  %2 = add i32 %0, 1
46*9880d681SAndroid Build Coastguard Worker  %3 = icmp eq i32 %2, %size
47*9880d681SAndroid Build Coastguard Worker  br i1 %3, label %for.end, label %for.body
48*9880d681SAndroid Build Coastguard Worker
49*9880d681SAndroid Build Coastguard Workerfor.end:
50*9880d681SAndroid Build Coastguard Worker  ret void
51*9880d681SAndroid Build Coastguard Worker}
52