blob: cffef339ee3347eb78e6e4f2791fe2405c2750f7 [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
Nate Begemand47d4f52008-01-25 05:34:48 +00006float4 foo = (float4){ 1.0, 2.0, 3.0, 4.0 };
Chris Lattner90997ac2007-08-03 16:42:43 +00007
8float4 test1(float4 V) {
9 return V.wzyx+V;
10}
11
12float2 vec2, vec2_2;
13float4 vec4, vec4_2;
14float f;
15
16static void test2() {
17 vec2 = vec4.rg; // shorten
18 f = vec2.x; // extract elt
19 vec4 = vec4.yyyy; // splat
20
21 vec2.x = f; // insert one.
22 vec2.yx = vec2; // reverse
23}
24
Devang Patela83cc332007-10-24 18:05:48 +000025static void test3(float4 *out) {
26 *out = ((float4) {1.0f, 2.0f, 3.0f, 4.0f });
27}
28
29static void test4(float4 *out) {
30 float a = 1.0f;
31 float b = 2.0f;
32 float c = 3.0f;
33 float d = 4.0f;
34 *out = ((float4) {a,b,c,d});
35}
Nate Begeman4119d1a2007-12-30 02:59:45 +000036
37static void test5(float4 *out) {
38 float a;
39 float4 b;
40
41 a = 1.0f;
42 b = a;
43 b = b * 5.0f;
44 b = 5.0f * b;
45 b *= a;
46
47 *out = b;
48}