John McCall | a7d6c22 | 2010-06-11 17:54:15 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -faltivec -triple powerpc-unknown-unknown -emit-llvm %s -o - | FileCheck %s |
| 2 | |
Anton Yartsev | d06fea8 | 2011-03-27 09:32:40 +0000 | [diff] [blame] | 3 | // Check initialization |
| 4 | |
| 5 | vector int test0 = (vector int)(1); // CHECK: @test0 = global <4 x i32> <i32 1, i32 1, i32 1, i32 1> |
| 6 | vector float test1 = (vector float)(1.0); // CHECK: @test1 = global <4 x float> <float 1.000000e+{{0+}}, float 1.000000e+{{0+}}, float 1.000000e+{{0+}}, float 1.000000e+{{0+}}> |
| 7 | |
Richard Smith | d62ca37 | 2011-12-06 22:44:34 +0000 | [diff] [blame^] | 8 | // CHECK: @v1 = global <16 x i8> bitcast (<4 x i32> <i32 1, i32 2, i32 3, i32 4> to <16 x i8>) |
| 9 | vector char v1 = (vector char)((vector int)(1, 2, 3, 4)); |
| 10 | // CHECK: @v2 = global <16 x i8> bitcast (<4 x float> <float 1.000000e+{{0+}}, float 2.000000e+{{0+}}, float 3.000000e+{{0+}}, float 4.000000e+{{0+}}> to <16 x i8>) |
| 11 | vector char v2 = (vector char)((vector float)(1.0f, 2.0f, 3.0f, 4.0f)); |
| 12 | // CHECK: @v3 = global <16 x i8> bitcast (<4 x i32> <i32 97, i32 98, i32 99, i32 100> to <16 x i8>) |
| 13 | vector char v3 = (vector char)((vector int)('a', 'b', 'c', 'd')); |
| 14 | // CHECK: @v4 = global <4 x i32> bitcast (<16 x i8> <i8 1, i8 2, i8 3, i8 4, i8 0, i8 0, i8 0, i8 0, i8 0, i8 0, i8 0, i8 0, i8 0, i8 0, i8 0, i8 0> to <4 x i32>) |
| 15 | vector int v4 = (vector char){1, 2, 3, 4}; |
| 16 | |
Anton Yartsev | d06fea8 | 2011-03-27 09:32:40 +0000 | [diff] [blame] | 17 | void test2() |
| 18 | { |
| 19 | vector int vi; |
| 20 | vector float vf; |
| 21 | vi = (vector int)(1); // CHECK: <i32 1, i32 1, i32 1, i32 1> |
| 22 | vf = (vector float)(1.0); // CHECK: <float 1.000000e+{{0+}}, float 1.000000e+{{0+}}, float 1.000000e+{{0+}}, float 1.000000e+{{0+}}> |
| 23 | vi = (vector int)(1, 2, 3, 4); // CHECK: <i32 1, i32 2, i32 3, i32 4> |
| 24 | vi = (vector int)(1, 2, 3, 4, 5); // CHECK: <i32 1, i32 2, i32 3, i32 4> |
| 25 | |
| 26 | vi = (vector int){1}; // CHECK: <i32 1, i32 0, i32 0, i32 0> |
| 27 | vi = (vector int){1, 2}; // CHECK: <i32 1, i32 2, i32 0, i32 0> |
| 28 | vi = (vector int){1, 2, 3, 4}; // CHECK: <i32 1, i32 2, i32 3, i32 4> |
| 29 | |
| 30 | } |
| 31 | |
| 32 | // Check pre/post increment/decrement |
| 33 | void test3() { |
| 34 | vector int vi; |
Eli Friedman | d4b9ee3 | 2011-05-06 18:04:18 +0000 | [diff] [blame] | 35 | vi++; // CHECK: add <4 x i32> {{.*}} <i32 1, i32 1, i32 1, i32 1> |
Anton Yartsev | d06fea8 | 2011-03-27 09:32:40 +0000 | [diff] [blame] | 36 | vector unsigned int vui; |
| 37 | --vui; // CHECK: add <4 x i32> {{.*}} <i32 -1, i32 -1, i32 -1, i32 -1> |
| 38 | vector float vf; |
| 39 | vf++; // CHECK: fadd <4 x float> {{.*}} <float 1.000000e+{{0+}}, float 1.000000e+{{0+}}, float 1.000000e+{{0+}}, float 1.000000e+{{0+}}> |
| 40 | } |