blob: ee6e737a5853eca52a0b4ed840331c848bfab0d6 [file] [log] [blame]
Chris Lattner90997ac2007-08-03 16:42:43 +00001// RUN: clang -emit-llvm %s
2
3typedef __attribute__(( ocu_vector_type(4) )) float float4;
Chris Lattner90997ac2007-08-03 16:42:43 +00004typedef __attribute__(( ocu_vector_type(2) )) float float2;
5
6
7float4 test1(float4 V) {
8 return V.wzyx+V;
9}
10
11float2 vec2, vec2_2;
12float4 vec4, vec4_2;
13float f;
14
15static void test2() {
16 vec2 = vec4.rg; // shorten
17 f = vec2.x; // extract elt
18 vec4 = vec4.yyyy; // splat
19
20 vec2.x = f; // insert one.
21 vec2.yx = vec2; // reverse
22}
23
Devang Patela83cc332007-10-24 18:05:48 +000024static void test3(float4 *out) {
25 *out = ((float4) {1.0f, 2.0f, 3.0f, 4.0f });
26}
27
28static void test4(float4 *out) {
29 float a = 1.0f;
30 float b = 2.0f;
31 float c = 3.0f;
32 float d = 4.0f;
33 *out = ((float4) {a,b,c,d});
34}
Nate Begeman4119d1a2007-12-30 02:59:45 +000035
36static void test5(float4 *out) {
37 float a;
38 float4 b;
39
40 a = 1.0f;
41 b = a;
42 b = b * 5.0f;
43 b = 5.0f * b;
44 b *= a;
45
46 *out = b;
47}