blob: 6c924a7fe36fe0020a6c6151e27e3f9d645d78df [file] [log] [blame]
Jim Grosbachf7947052012-07-09 18:34:21 +00001// REQUIRES: ppc32-registered-target
John McCalla7d6c222010-06-11 17:54:15 +00002// RUN: %clang_cc1 -faltivec -triple powerpc-unknown-unknown -emit-llvm %s -o - | FileCheck %s
3
Anton Yartsevd06fea82011-03-27 09:32:40 +00004// Check initialization
5
6vector int test0 = (vector int)(1); // CHECK: @test0 = global <4 x i32> <i32 1, i32 1, i32 1, i32 1>
7vector 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+}}>
8
Eli Friedmane6a24e82011-12-22 03:51:45 +00009// CHECK: @v1 = global <16 x i8> <i8 0, i8 0, i8 0, i8 1, i8 0, i8 0, i8 0, i8 2, i8 0, i8 0, i8 0, i8 3, i8 0, i8 0, i8 0, i8 4>
Richard Smithd62ca372011-12-06 22:44:34 +000010vector char v1 = (vector char)((vector int)(1, 2, 3, 4));
Eli Friedmane6a24e82011-12-22 03:51:45 +000011// CHECK: @v2 = global <16 x i8> <i8 63, i8 -128, i8 0, i8 0, i8 64, i8 0, i8 0, i8 0, i8 64, i8 64, i8 0, i8 0, i8 64, i8 -128, i8 0, i8 0>
Richard Smithd62ca372011-12-06 22:44:34 +000012vector char v2 = (vector char)((vector float)(1.0f, 2.0f, 3.0f, 4.0f));
Eli Friedmane6a24e82011-12-22 03:51:45 +000013// CHECK: @v3 = global <16 x i8> <i8 0, i8 0, i8 0, i8 97, i8 0, i8 0, i8 0, i8 98, i8 0, i8 0, i8 0, i8 99, i8 0, i8 0, i8 0, i8 100>
Richard Smithd62ca372011-12-06 22:44:34 +000014vector char v3 = (vector char)((vector int)('a', 'b', 'c', 'd'));
Eli Friedmane6a24e82011-12-22 03:51:45 +000015// CHECK: @v4 = global <4 x i32> <i32 16909060, i32 0, i32 0, i32 0>
Richard Smithd62ca372011-12-06 22:44:34 +000016vector int v4 = (vector char){1, 2, 3, 4};
17
Anton Yartsevd06fea82011-03-27 09:32:40 +000018void test2()
19{
20 vector int vi;
21 vector float vf;
22 vi = (vector int)(1); // CHECK: <i32 1, i32 1, i32 1, i32 1>
23 vf = (vector float)(1.0); // CHECK: <float 1.000000e+{{0+}}, float 1.000000e+{{0+}}, float 1.000000e+{{0+}}, float 1.000000e+{{0+}}>
24 vi = (vector int)(1, 2, 3, 4); // CHECK: <i32 1, i32 2, i32 3, i32 4>
25 vi = (vector int)(1, 2, 3, 4, 5); // CHECK: <i32 1, i32 2, i32 3, i32 4>
26
27 vi = (vector int){1}; // CHECK: <i32 1, i32 0, i32 0, i32 0>
28 vi = (vector int){1, 2}; // CHECK: <i32 1, i32 2, i32 0, i32 0>
29 vi = (vector int){1, 2, 3, 4}; // CHECK: <i32 1, i32 2, i32 3, i32 4>
30
31}
32
33// Check pre/post increment/decrement
34void test3() {
35 vector int vi;
Eli Friedmand4b9ee32011-05-06 18:04:18 +000036 vi++; // CHECK: add <4 x i32> {{.*}} <i32 1, i32 1, i32 1, i32 1>
Anton Yartsevd06fea82011-03-27 09:32:40 +000037 vector unsigned int vui;
38 --vui; // CHECK: add <4 x i32> {{.*}} <i32 -1, i32 -1, i32 -1, i32 -1>
39 vector float vf;
40 vf++; // CHECK: fadd <4 x float> {{.*}} <float 1.000000e+{{0+}}, float 1.000000e+{{0+}}, float 1.000000e+{{0+}}, float 1.000000e+{{0+}}>
41}