• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // RUN: %clang_cc1 -faltivec -triple powerpc-unknown-unknown -emit-llvm %s -o - | FileCheck %s
2 
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 
8 // 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>
9 vector char v1 = (vector char)((vector int)(1, 2, 3, 4));
10 // 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>
11 vector char v2 = (vector char)((vector float)(1.0f, 2.0f, 3.0f, 4.0f));
12 // 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>
13 vector char v3 = (vector char)((vector int)('a', 'b', 'c', 'd'));
14 // CHECK: @v4 = global <4 x i32> <i32 16909060, i32 0, i32 0, i32 0>
15 vector int v4 = (vector char){1, 2, 3, 4};
16 
test2()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
test3()33 void test3() {
34   vector int vi;
35   vi++;                                    // CHECK: add <4 x i32> {{.*}} <i32 1, i32 1, i32 1, i32 1>
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 }
41