blob: bd694a6a56deddc0713291e12f11b3b0a3a0081d [file] [log] [blame]
John McCalla7d6c222010-06-11 17:54:15 +00001// RUN: %clang_cc1 -faltivec -triple powerpc-unknown-unknown -emit-llvm %s -o - | FileCheck %s
2
Anton Yartsevd06fea82011-03-27 09:32:40 +00003// Check initialization
4
5vector int test0 = (vector int)(1); // CHECK: @test0 = global <4 x i32> <i32 1, i32 1, i32 1, i32 1>
6vector 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 Smithd62ca372011-12-06 22:44:34 +00008// CHECK: @v1 = global <16 x i8> bitcast (<4 x i32> <i32 1, i32 2, i32 3, i32 4> to <16 x i8>)
9vector 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>)
11vector 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>)
13vector 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>)
15vector int v4 = (vector char){1, 2, 3, 4};
16
Anton Yartsevd06fea82011-03-27 09:32:40 +000017void 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
33void test3() {
34 vector int vi;
Eli Friedmand4b9ee32011-05-06 18:04:18 +000035 vi++; // CHECK: add <4 x i32> {{.*}} <i32 1, i32 1, i32 1, i32 1>
Anton Yartsevd06fea82011-03-27 09:32:40 +000036 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}