]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/CodeGen/R600/vector-alloca.ll
Vendor import of llvm RELEASE_350/final tag r216957 (effectively, 3.5.0 release):
[FreeBSD/FreeBSD.git] / test / CodeGen / R600 / vector-alloca.ll
1 ; RUN: llc -march=r600 -mcpu=redwood < %s | FileCheck --check-prefix=EG -check-prefix=FUNC %s
2 ; RUN: llc -march=r600 -mcpu=verde -mattr=-promote-alloca -verify-machineinstrs < %s | FileCheck -check-prefix=SI-ALLOCA -check-prefix=SI -check-prefix=FUNC %s
3 ; RUN: llc -march=r600 -mcpu=verde -mattr=+promote-alloca -verify-machineinstrs < %s | FileCheck -check-prefix=SI-PROMOTE -check-prefix=SI -check-prefix=FUNC %s
4
5 ; FUNC-LABEL: @vector_read
6 ; EG: MOV
7 ; EG: MOV
8 ; EG: MOV
9 ; EG: MOV
10 ; EG: MOVA_INT
11 define void @vector_read(i32 addrspace(1)* %out, i32 %index) {
12 entry:
13   %0 = alloca [4 x i32]
14   %x = getelementptr [4 x i32]* %0, i32 0, i32 0
15   %y = getelementptr [4 x i32]* %0, i32 0, i32 1
16   %z = getelementptr [4 x i32]* %0, i32 0, i32 2
17   %w = getelementptr [4 x i32]* %0, i32 0, i32 3
18   store i32 0, i32* %x
19   store i32 1, i32* %y
20   store i32 2, i32* %z
21   store i32 3, i32* %w
22   %1 = getelementptr [4 x i32]* %0, i32 0, i32 %index
23   %2 = load i32* %1
24   store i32 %2, i32 addrspace(1)* %out
25   ret void
26 }
27
28 ; FUNC-LABEL: @vector_write
29 ; EG: MOV
30 ; EG: MOV
31 ; EG: MOV
32 ; EG: MOV
33 ; EG: MOVA_INT
34 ; EG: MOVA_INT
35 define void @vector_write(i32 addrspace(1)* %out, i32 %w_index, i32 %r_index) {
36 entry:
37   %0 = alloca [4 x i32]
38   %x = getelementptr [4 x i32]* %0, i32 0, i32 0
39   %y = getelementptr [4 x i32]* %0, i32 0, i32 1
40   %z = getelementptr [4 x i32]* %0, i32 0, i32 2
41   %w = getelementptr [4 x i32]* %0, i32 0, i32 3
42   store i32 0, i32* %x
43   store i32 0, i32* %y
44   store i32 0, i32* %z
45   store i32 0, i32* %w
46   %1 = getelementptr [4 x i32]* %0, i32 0, i32 %w_index
47   store i32 1, i32* %1
48   %2 = getelementptr [4 x i32]* %0, i32 0, i32 %r_index
49   %3 = load i32* %2
50   store i32 %3, i32 addrspace(1)* %out
51   ret void
52 }
53
54 ; This test should be optimize to:
55 ; store i32 0, i32 addrspace(1)* %out
56 ; FUNC-LABEL: @bitcast_gep
57 ; EG: STORE_RAW
58 define void @bitcast_gep(i32 addrspace(1)* %out, i32 %w_index, i32 %r_index) {
59 entry:
60   %0 = alloca [4 x i32]
61   %x = getelementptr [4 x i32]* %0, i32 0, i32 0
62   %y = getelementptr [4 x i32]* %0, i32 0, i32 1
63   %z = getelementptr [4 x i32]* %0, i32 0, i32 2
64   %w = getelementptr [4 x i32]* %0, i32 0, i32 3
65   store i32 0, i32* %x
66   store i32 0, i32* %y
67   store i32 0, i32* %z
68   store i32 0, i32* %w
69   %1 = getelementptr [4 x i32]* %0, i32 0, i32 1
70   %2 = bitcast i32* %1 to [4 x i32]*
71   %3 = getelementptr [4 x i32]* %2, i32 0, i32 0
72   %4 = load i32* %3
73   store i32 %4, i32 addrspace(1)* %out
74   ret void
75 }