Eli Friedman | 87b9c03 | 2012-04-05 21:48:40 +0000 | [diff] [blame] | 1 | // RUN: %clang -emit-llvm -S -o - %s | FileCheck %s |
| 2 | |
| 3 | typedef float float4 __attribute__((ext_vector_type(4))); |
| 4 | typedef unsigned int uint4 __attribute__((ext_vector_type(4))); |
| 5 | |
Stephen Lin | 93ab6bf | 2013-08-15 06:47:53 +0000 | [diff] [blame] | 6 | // CHECK-LABEL: define void @clang_shufflevector_v_v( |
Eli Friedman | 87b9c03 | 2012-04-05 21:48:40 +0000 | [diff] [blame] | 7 | void clang_shufflevector_v_v( float4* A, float4 x, uint4 mask ) { |
| 8 | // CHECK: [[MASK:%.*]] = and <4 x i32> {{%.*}}, <i32 3, i32 3, i32 3, i32 3> |
Stephen Hines | c568f1e | 2014-07-21 00:47:37 -0700 | [diff] [blame] | 9 | // CHECK: [[I:%.*]] = extractelement <4 x i32> [[MASK]], i{{[0-9]+}} 0 |
| 10 | // CHECK: [[E:%.*]] = extractelement <4 x float> [[X:%.*]], i{{[0-9]+}} [[I]] |
Eli Friedman | 87b9c03 | 2012-04-05 21:48:40 +0000 | [diff] [blame] | 11 | // |
| 12 | // Here is where ToT Clang code generation makes a mistake. |
| 13 | // It uses [[I]] as the insertion index instead of 0. |
| 14 | // Similarly on the remaining insertelement. |
Stephen Hines | c568f1e | 2014-07-21 00:47:37 -0700 | [diff] [blame] | 15 | // CHECK: [[V:%[a-zA-Z0-9._]+]] = insertelement <4 x float> undef, float [[E]], i{{[0-9]+}} 0 |
Eli Friedman | 87b9c03 | 2012-04-05 21:48:40 +0000 | [diff] [blame] | 16 | |
Stephen Hines | c568f1e | 2014-07-21 00:47:37 -0700 | [diff] [blame] | 17 | // CHECK: [[I:%.*]] = extractelement <4 x i32> [[MASK]], i{{[0-9]+}} 1 |
| 18 | // CHECK: [[E:%.*]] = extractelement <4 x float> [[X]], i{{[0-9]+}} [[I]] |
| 19 | // CHECK: [[V2:%.*]] = insertelement <4 x float> [[V]], float [[E]], i{{[0-9]+}} 1 |
| 20 | // CHECK: [[I:%.*]] = extractelement <4 x i32> [[MASK]], i{{[0-9]+}} 2 |
| 21 | // CHECK: [[E:%.*]] = extractelement <4 x float> [[X]], i{{[0-9]+}} [[I]] |
| 22 | // CHECK: [[V3:%.*]] = insertelement <4 x float> [[V2]], float [[E]], i{{[0-9]+}} 2 |
| 23 | // CHECK: [[I:%.*]] = extractelement <4 x i32> [[MASK]], i{{[0-9]+}} 3 |
| 24 | // CHECK: [[E:%.*]] = extractelement <4 x float> [[X]], i{{[0-9]+}} [[I]] |
| 25 | // CHECK: [[V4:%.*]] = insertelement <4 x float> [[V3]], float [[E]], i{{[0-9]+}} 3 |
Eli Bendersky | ac55865 | 2012-12-01 13:50:51 +0000 | [diff] [blame] | 26 | // CHECK: store <4 x float> [[V4]], <4 x float>* {{%.*}}, |
Eli Friedman | 87b9c03 | 2012-04-05 21:48:40 +0000 | [diff] [blame] | 27 | *A = __builtin_shufflevector( x, mask ); |
| 28 | } |
| 29 | |
Stephen Lin | 93ab6bf | 2013-08-15 06:47:53 +0000 | [diff] [blame] | 30 | // CHECK-LABEL: define void @clang_shufflevector_v_v_c( |
Craig Topper | 6f4f808 | 2013-08-03 17:40:38 +0000 | [diff] [blame] | 31 | void clang_shufflevector_v_v_c( float4* A, float4 x, float4 y) { |
Eli Friedman | 87b9c03 | 2012-04-05 21:48:40 +0000 | [diff] [blame] | 32 | // CHECK: [[V:%.*]] = shufflevector <4 x float> {{%.*}}, <4 x float> {{%.*}}, <4 x i32> <i32 0, i32 4, i32 1, i32 5> |
| 33 | // CHECK: store <4 x float> [[V]], <4 x float>* {{%.*}} |
| 34 | *A = __builtin_shufflevector( x, y, 0, 4, 1, 5 ); |
| 35 | } |
Craig Topper | 6f4f808 | 2013-08-03 17:40:38 +0000 | [diff] [blame] | 36 | |
Stephen Lin | 93ab6bf | 2013-08-15 06:47:53 +0000 | [diff] [blame] | 37 | // CHECK-LABEL: define void @clang_shufflevector_v_v_undef( |
Craig Topper | 6f4f808 | 2013-08-03 17:40:38 +0000 | [diff] [blame] | 38 | void clang_shufflevector_v_v_undef( float4* A, float4 x, float4 y) { |
| 39 | // CHECK: [[V:%.*]] = shufflevector <4 x float> {{%.*}}, <4 x float> {{%.*}}, <4 x i32> <i32 0, i32 4, i32 undef, i32 5> |
| 40 | // CHECK: store <4 x float> [[V]], <4 x float>* {{%.*}} |
| 41 | *A = __builtin_shufflevector( x, y, 0, 4, -1, 5 ); |
| 42 | } |