2012-04-06 05:48:40 +08:00
|
|
|
// RUN: %clang -emit-llvm -S -o - %s | FileCheck %s
|
|
|
|
|
|
|
|
typedef float float4 __attribute__((ext_vector_type(4)));
|
|
|
|
typedef unsigned int uint4 __attribute__((ext_vector_type(4)));
|
|
|
|
|
2013-08-15 14:47:53 +08:00
|
|
|
// CHECK-LABEL: define void @clang_shufflevector_v_v(
|
2012-04-06 05:48:40 +08:00
|
|
|
void clang_shufflevector_v_v( float4* A, float4 x, uint4 mask ) {
|
|
|
|
// CHECK: [[MASK:%.*]] = and <4 x i32> {{%.*}}, <i32 3, i32 3, i32 3, i32 3>
|
2014-05-31 08:22:12 +08:00
|
|
|
// CHECK: [[I:%.*]] = extractelement <4 x i32> [[MASK]], i{{[0-9]+}} 0
|
|
|
|
// CHECK: [[E:%.*]] = extractelement <4 x float> [[X:%.*]], i{{[0-9]+}} [[I]]
|
2012-04-06 05:48:40 +08:00
|
|
|
//
|
|
|
|
// Here is where ToT Clang code generation makes a mistake.
|
|
|
|
// It uses [[I]] as the insertion index instead of 0.
|
|
|
|
// Similarly on the remaining insertelement.
|
2014-05-31 08:22:12 +08:00
|
|
|
// CHECK: [[V:%[a-zA-Z0-9._]+]] = insertelement <4 x float> undef, float [[E]], i{{[0-9]+}} 0
|
2012-04-06 05:48:40 +08:00
|
|
|
|
2014-05-31 08:22:12 +08:00
|
|
|
// CHECK: [[I:%.*]] = extractelement <4 x i32> [[MASK]], i{{[0-9]+}} 1
|
|
|
|
// CHECK: [[E:%.*]] = extractelement <4 x float> [[X]], i{{[0-9]+}} [[I]]
|
|
|
|
// CHECK: [[V2:%.*]] = insertelement <4 x float> [[V]], float [[E]], i{{[0-9]+}} 1
|
|
|
|
// CHECK: [[I:%.*]] = extractelement <4 x i32> [[MASK]], i{{[0-9]+}} 2
|
|
|
|
// CHECK: [[E:%.*]] = extractelement <4 x float> [[X]], i{{[0-9]+}} [[I]]
|
|
|
|
// CHECK: [[V3:%.*]] = insertelement <4 x float> [[V2]], float [[E]], i{{[0-9]+}} 2
|
|
|
|
// CHECK: [[I:%.*]] = extractelement <4 x i32> [[MASK]], i{{[0-9]+}} 3
|
|
|
|
// CHECK: [[E:%.*]] = extractelement <4 x float> [[X]], i{{[0-9]+}} [[I]]
|
|
|
|
// CHECK: [[V4:%.*]] = insertelement <4 x float> [[V3]], float [[E]], i{{[0-9]+}} 3
|
2012-12-01 21:50:51 +08:00
|
|
|
// CHECK: store <4 x float> [[V4]], <4 x float>* {{%.*}},
|
2012-04-06 05:48:40 +08:00
|
|
|
*A = __builtin_shufflevector( x, mask );
|
|
|
|
}
|
|
|
|
|
2013-08-15 14:47:53 +08:00
|
|
|
// CHECK-LABEL: define void @clang_shufflevector_v_v_c(
|
2013-08-04 01:40:38 +08:00
|
|
|
void clang_shufflevector_v_v_c( float4* A, float4 x, float4 y) {
|
2012-04-06 05:48:40 +08:00
|
|
|
// CHECK: [[V:%.*]] = shufflevector <4 x float> {{%.*}}, <4 x float> {{%.*}}, <4 x i32> <i32 0, i32 4, i32 1, i32 5>
|
|
|
|
// CHECK: store <4 x float> [[V]], <4 x float>* {{%.*}}
|
|
|
|
*A = __builtin_shufflevector( x, y, 0, 4, 1, 5 );
|
|
|
|
}
|
2013-08-04 01:40:38 +08:00
|
|
|
|
2013-08-15 14:47:53 +08:00
|
|
|
// CHECK-LABEL: define void @clang_shufflevector_v_v_undef(
|
2013-08-04 01:40:38 +08:00
|
|
|
void clang_shufflevector_v_v_undef( float4* A, float4 x, float4 y) {
|
|
|
|
// CHECK: [[V:%.*]] = shufflevector <4 x float> {{%.*}}, <4 x float> {{%.*}}, <4 x i32> <i32 0, i32 4, i32 undef, i32 5>
|
|
|
|
// CHECK: store <4 x float> [[V]], <4 x float>* {{%.*}}
|
|
|
|
*A = __builtin_shufflevector( x, y, 0, 4, -1, 5 );
|
|
|
|
}
|