Chris Lattner | 90997ac | 2007-08-03 16:42:43 +0000 | [diff] [blame] | 1 | // RUN: clang -emit-llvm %s |
| 2 | |
| 3 | typedef __attribute__(( ocu_vector_type(4) )) float float4; |
Chris Lattner | 90997ac | 2007-08-03 16:42:43 +0000 | [diff] [blame] | 4 | typedef __attribute__(( ocu_vector_type(2) )) float float2; |
| 5 | |
| 6 | |
| 7 | float4 test1(float4 V) { |
| 8 | return V.wzyx+V; |
| 9 | } |
| 10 | |
| 11 | float2 vec2, vec2_2; |
| 12 | float4 vec4, vec4_2; |
| 13 | float f; |
| 14 | |
| 15 | static 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 Patel | a83cc33 | 2007-10-24 18:05:48 +0000 | [diff] [blame] | 24 | static void test3(float4 *out) { |
| 25 | *out = ((float4) {1.0f, 2.0f, 3.0f, 4.0f }); |
| 26 | } |
| 27 | |
| 28 | static 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 Begeman | 4119d1a | 2007-12-30 02:59:45 +0000 | [diff] [blame^] | 35 | |
| 36 | static 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 | } |