Jim Grosbach | f794705 | 2012-07-09 18:34:21 +0000 | [diff] [blame] | 1 | // REQUIRES: ppc32-registered-target |
John McCall | a7d6c22 | 2010-06-11 17:54:15 +0000 | [diff] [blame] | 2 | // RUN: %clang_cc1 -faltivec -triple powerpc-unknown-unknown -emit-llvm %s -o - | FileCheck %s |
| 3 | |
Anton Yartsev | d06fea8 | 2011-03-27 09:32:40 +0000 | [diff] [blame] | 4 | // Check initialization |
| 5 | |
| 6 | vector int test0 = (vector int)(1); // CHECK: @test0 = global <4 x i32> <i32 1, i32 1, i32 1, i32 1> |
| 7 | 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+}}> |
| 8 | |
Eli Friedman | e6a24e8 | 2011-12-22 03:51:45 +0000 | [diff] [blame] | 9 | // 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 Smith | d62ca37 | 2011-12-06 22:44:34 +0000 | [diff] [blame] | 10 | vector char v1 = (vector char)((vector int)(1, 2, 3, 4)); |
Eli Friedman | e6a24e8 | 2011-12-22 03:51:45 +0000 | [diff] [blame] | 11 | // 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 Smith | d62ca37 | 2011-12-06 22:44:34 +0000 | [diff] [blame] | 12 | vector char v2 = (vector char)((vector float)(1.0f, 2.0f, 3.0f, 4.0f)); |
Eli Friedman | e6a24e8 | 2011-12-22 03:51:45 +0000 | [diff] [blame] | 13 | // 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 Smith | d62ca37 | 2011-12-06 22:44:34 +0000 | [diff] [blame] | 14 | vector char v3 = (vector char)((vector int)('a', 'b', 'c', 'd')); |
Eli Friedman | e6a24e8 | 2011-12-22 03:51:45 +0000 | [diff] [blame] | 15 | // CHECK: @v4 = global <4 x i32> <i32 16909060, i32 0, i32 0, i32 0> |
Richard Smith | d62ca37 | 2011-12-06 22:44:34 +0000 | [diff] [blame] | 16 | vector int v4 = (vector char){1, 2, 3, 4}; |
| 17 | |
Anton Yartsev | d06fea8 | 2011-03-27 09:32:40 +0000 | [diff] [blame] | 18 | void 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 |
| 34 | void test3() { |
| 35 | vector int vi; |
Eli Friedman | d4b9ee3 | 2011-05-06 18:04:18 +0000 | [diff] [blame] | 36 | 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] | 37 | 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 | } |