llvm-ar: Clean up memory management with OwningPtr.
[oota-llvm.git] / test / CodeGen / R600 / literals.ll
1 ; RUN: llc < %s -march=r600 -mcpu=redwood | FileCheck %s
2
3 ; Test using an integer literal constant.
4 ; Generated ASM should be:
5 ; ADD_INT REG literal.x, 5
6 ; or
7 ; ADD_INT literal.x REG, 5
8
9 ; CHECK: @i32_literal
10 ; CHECK: ADD_INT * {{[A-Z0-9,. ]*}}literal.x
11 ; CHECK-NEXT: 5
12 define void @i32_literal(i32 addrspace(1)* %out, i32 %in) {
13 entry:
14   %0 = add i32 5, %in
15   store i32 %0, i32 addrspace(1)* %out
16   ret void
17 }
18
19 ; Test using a float literal constant.
20 ; Generated ASM should be:
21 ; ADD REG literal.x, 5.0
22 ; or
23 ; ADD literal.x REG, 5.0
24
25 ; CHECK: @float_literal
26 ; CHECK: ADD * {{[A-Z0-9,. ]*}}literal.x
27 ; CHECK-NEXT: 1084227584(5.0
28 define void @float_literal(float addrspace(1)* %out, float %in) {
29 entry:
30   %0 = fadd float 5.0, %in
31   store float %0, float addrspace(1)* %out
32   ret void
33 }
34
35 ; CHECK: @main
36 ; CHECK: -2147483648
37 ; CHECK-NEXT-NOT: -2147483648
38
39 define void @main() #0 {
40 main_body:
41   %0 = call float @llvm.R600.load.input(i32 4)
42   %1 = call float @llvm.R600.load.input(i32 5)
43   %2 = call float @llvm.R600.load.input(i32 6)
44   %3 = call float @llvm.R600.load.input(i32 7)
45   %4 = call float @llvm.R600.load.input(i32 8)
46   %5 = call float @llvm.R600.load.input(i32 9)
47   %6 = call float @llvm.R600.load.input(i32 10)
48   %7 = call float @llvm.R600.load.input(i32 11)
49   %8 = call float @llvm.R600.load.input(i32 12)
50   %9 = call float @llvm.R600.load.input(i32 13)
51   %10 = call float @llvm.R600.load.input(i32 14)
52   %11 = call float @llvm.R600.load.input(i32 15)
53   %12 = load <4 x float> addrspace(8)* null
54   %13 = extractelement <4 x float> %12, i32 0
55   %14 = fsub float -0.000000e+00, %13
56   %15 = fadd float %0, %14
57   %16 = load <4 x float> addrspace(8)* null
58   %17 = extractelement <4 x float> %16, i32 1
59   %18 = fsub float -0.000000e+00, %17
60   %19 = fadd float %1, %18
61   %20 = load <4 x float> addrspace(8)* null
62   %21 = extractelement <4 x float> %20, i32 2
63   %22 = fsub float -0.000000e+00, %21
64   %23 = fadd float %2, %22
65   %24 = load <4 x float> addrspace(8)* getelementptr ([1024 x <4 x float>] addrspace(8)* null, i64 0, i32 1)
66   %25 = extractelement <4 x float> %24, i32 0
67   %26 = fmul float %25, %0
68   %27 = load <4 x float> addrspace(8)* getelementptr ([1024 x <4 x float>] addrspace(8)* null, i64 0, i32 1)
69   %28 = extractelement <4 x float> %27, i32 1
70   %29 = fmul float %28, %0
71   %30 = load <4 x float> addrspace(8)* getelementptr ([1024 x <4 x float>] addrspace(8)* null, i64 0, i32 1)
72   %31 = extractelement <4 x float> %30, i32 2
73   %32 = fmul float %31, %0
74   %33 = load <4 x float> addrspace(8)* getelementptr ([1024 x <4 x float>] addrspace(8)* null, i64 0, i32 1)
75   %34 = extractelement <4 x float> %33, i32 3
76   %35 = fmul float %34, %0
77   %36 = load <4 x float> addrspace(8)* getelementptr ([1024 x <4 x float>] addrspace(8)* null, i64 0, i32 2)
78   %37 = extractelement <4 x float> %36, i32 0
79   %38 = fmul float %37, %1
80   %39 = fadd float %38, %26
81   %40 = load <4 x float> addrspace(8)* getelementptr ([1024 x <4 x float>] addrspace(8)* null, i64 0, i32 2)
82   %41 = extractelement <4 x float> %40, i32 1
83   %42 = fmul float %41, %1
84   %43 = fadd float %42, %29
85   %44 = load <4 x float> addrspace(8)* getelementptr ([1024 x <4 x float>] addrspace(8)* null, i64 0, i32 2)
86   %45 = extractelement <4 x float> %44, i32 2
87   %46 = fmul float %45, %1
88   %47 = fadd float %46, %32
89   %48 = load <4 x float> addrspace(8)* getelementptr ([1024 x <4 x float>] addrspace(8)* null, i64 0, i32 2)
90   %49 = extractelement <4 x float> %48, i32 3
91   %50 = fmul float %49, %1
92   %51 = fadd float %50, %35
93   %52 = load <4 x float> addrspace(8)* getelementptr ([1024 x <4 x float>] addrspace(8)* null, i64 0, i32 3)
94   %53 = extractelement <4 x float> %52, i32 0
95   %54 = fmul float %53, %2
96   %55 = fadd float %54, %39
97   %56 = load <4 x float> addrspace(8)* getelementptr ([1024 x <4 x float>] addrspace(8)* null, i64 0, i32 3)
98   %57 = extractelement <4 x float> %56, i32 1
99   %58 = fmul float %57, %2
100   %59 = fadd float %58, %43
101   %60 = load <4 x float> addrspace(8)* getelementptr ([1024 x <4 x float>] addrspace(8)* null, i64 0, i32 3)
102   %61 = extractelement <4 x float> %60, i32 2
103   %62 = fmul float %61, %2
104   %63 = fadd float %62, %47
105   %64 = load <4 x float> addrspace(8)* getelementptr ([1024 x <4 x float>] addrspace(8)* null, i64 0, i32 3)
106   %65 = extractelement <4 x float> %64, i32 3
107   %66 = fmul float %65, %2
108   %67 = fadd float %66, %51
109   %68 = load <4 x float> addrspace(8)* getelementptr ([1024 x <4 x float>] addrspace(8)* null, i64 0, i32 4)
110   %69 = extractelement <4 x float> %68, i32 0
111   %70 = fmul float %69, %3
112   %71 = fadd float %70, %55
113   %72 = load <4 x float> addrspace(8)* getelementptr ([1024 x <4 x float>] addrspace(8)* null, i64 0, i32 4)
114   %73 = extractelement <4 x float> %72, i32 1
115   %74 = fmul float %73, %3
116   %75 = fadd float %74, %59
117   %76 = load <4 x float> addrspace(8)* getelementptr ([1024 x <4 x float>] addrspace(8)* null, i64 0, i32 4)
118   %77 = extractelement <4 x float> %76, i32 2
119   %78 = fmul float %77, %3
120   %79 = fadd float %78, %63
121   %80 = load <4 x float> addrspace(8)* getelementptr ([1024 x <4 x float>] addrspace(8)* null, i64 0, i32 4)
122   %81 = extractelement <4 x float> %80, i32 3
123   %82 = fmul float %81, %3
124   %83 = fadd float %82, %67
125   %84 = insertelement <4 x float> undef, float %15, i32 0
126   %85 = insertelement <4 x float> %84, float %19, i32 1
127   %86 = insertelement <4 x float> %85, float %23, i32 2
128   %87 = insertelement <4 x float> %86, float 0.000000e+00, i32 3
129   %88 = insertelement <4 x float> undef, float %15, i32 0
130   %89 = insertelement <4 x float> %88, float %19, i32 1
131   %90 = insertelement <4 x float> %89, float %23, i32 2
132   %91 = insertelement <4 x float> %90, float 0.000000e+00, i32 3
133   %92 = call float @llvm.AMDGPU.dp4(<4 x float> %87, <4 x float> %91)
134   %93 = call float @fabs(float %92)
135   %94 = call float @llvm.AMDGPU.rsq(float %93)
136   %95 = fmul float %15, %94
137   %96 = fmul float %19, %94
138   %97 = fmul float %23, %94
139   %98 = insertelement <4 x float> undef, float %4, i32 0
140   %99 = insertelement <4 x float> %98, float %5, i32 1
141   %100 = insertelement <4 x float> %99, float %6, i32 2
142   %101 = insertelement <4 x float> %100, float 0.000000e+00, i32 3
143   %102 = insertelement <4 x float> undef, float %4, i32 0
144   %103 = insertelement <4 x float> %102, float %5, i32 1
145   %104 = insertelement <4 x float> %103, float %6, i32 2
146   %105 = insertelement <4 x float> %104, float 0.000000e+00, i32 3
147   %106 = call float @llvm.AMDGPU.dp4(<4 x float> %101, <4 x float> %105)
148   %107 = call float @fabs(float %106)
149   %108 = call float @llvm.AMDGPU.rsq(float %107)
150   %109 = fmul float %4, %108
151   %110 = fmul float %5, %108
152   %111 = fmul float %6, %108
153   %112 = insertelement <4 x float> undef, float %95, i32 0
154   %113 = insertelement <4 x float> %112, float %96, i32 1
155   %114 = insertelement <4 x float> %113, float %97, i32 2
156   %115 = insertelement <4 x float> %114, float 0.000000e+00, i32 3
157   %116 = insertelement <4 x float> undef, float %109, i32 0
158   %117 = insertelement <4 x float> %116, float %110, i32 1
159   %118 = insertelement <4 x float> %117, float %111, i32 2
160   %119 = insertelement <4 x float> %118, float 0.000000e+00, i32 3
161   %120 = call float @llvm.AMDGPU.dp4(<4 x float> %115, <4 x float> %119)
162   %121 = fsub float -0.000000e+00, %120
163   %122 = fcmp uge float 0.000000e+00, %121
164   %123 = select i1 %122, float 0.000000e+00, float %121
165   %124 = insertelement <4 x float> undef, float %8, i32 0
166   %125 = insertelement <4 x float> %124, float %9, i32 1
167   %126 = insertelement <4 x float> %125, float 5.000000e-01, i32 2
168   %127 = insertelement <4 x float> %126, float 1.000000e+00, i32 3
169   call void @llvm.R600.store.swizzle(<4 x float> %127, i32 60, i32 1)
170   %128 = insertelement <4 x float> undef, float %71, i32 0
171   %129 = insertelement <4 x float> %128, float %75, i32 1
172   %130 = insertelement <4 x float> %129, float %79, i32 2
173   %131 = insertelement <4 x float> %130, float %83, i32 3
174   call void @llvm.R600.store.swizzle(<4 x float> %131, i32 0, i32 2)
175   %132 = insertelement <4 x float> undef, float %123, i32 0
176   %133 = insertelement <4 x float> %132, float %96, i32 1
177   %134 = insertelement <4 x float> %133, float %97, i32 2
178   %135 = insertelement <4 x float> %134, float 0.000000e+00, i32 3
179   call void @llvm.R600.store.swizzle(<4 x float> %135, i32 1, i32 2)
180   ret void
181 }
182
183 ; Function Attrs: readnone
184 declare float @llvm.R600.load.input(i32) #1
185
186 ; Function Attrs: readnone
187 declare float @llvm.AMDGPU.dp4(<4 x float>, <4 x float>) #1
188
189 ; Function Attrs: readonly
190 declare float @fabs(float) #2
191
192 ; Function Attrs: readnone
193 declare float @llvm.AMDGPU.rsq(float) #1
194
195 declare void @llvm.R600.store.swizzle(<4 x float>, i32, i32)
196
197 attributes #0 = { "ShaderType"="1" }
198 attributes #1 = { readnone }
199 attributes #2 = { readonly }