43 lines · c
1// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s2 3typedef float float4 __attribute__((ext_vector_type(4)));4typedef unsigned int uint4 __attribute__((ext_vector_type(4)));5 6// CHECK-LABEL: define {{.*}}void @clang_shufflevector_v_v(7void clang_shufflevector_v_v( float4* A, float4 x, uint4 mask ) {8// CHECK: [[MASK:%.*]] = and <4 x i32> {{%.*}}, splat (i32 3)9// CHECK: [[I:%.*]] = extractelement <4 x i32> [[MASK]], i{{[0-9]+}} 010// CHECK: [[E:%.*]] = extractelement <4 x float> [[X:%.*]], i{{[0-9]+}} [[I]]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.15// CHECK: [[V:%[a-zA-Z0-9._]+]] = insertelement <4 x float> poison, float [[E]], i{{[0-9]+}} 016 17// CHECK: [[I:%.*]] = extractelement <4 x i32> [[MASK]], i{{[0-9]+}} 118// CHECK: [[E:%.*]] = extractelement <4 x float> [[X]], i{{[0-9]+}} [[I]]19// CHECK: [[V2:%.*]] = insertelement <4 x float> [[V]], float [[E]], i{{[0-9]+}} 120// CHECK: [[I:%.*]] = extractelement <4 x i32> [[MASK]], i{{[0-9]+}} 221// CHECK: [[E:%.*]] = extractelement <4 x float> [[X]], i{{[0-9]+}} [[I]]22// CHECK: [[V3:%.*]] = insertelement <4 x float> [[V2]], float [[E]], i{{[0-9]+}} 223// CHECK: [[I:%.*]] = extractelement <4 x i32> [[MASK]], i{{[0-9]+}} 324// CHECK: [[E:%.*]] = extractelement <4 x float> [[X]], i{{[0-9]+}} [[I]]25// CHECK: [[V4:%.*]] = insertelement <4 x float> [[V3]], float [[E]], i{{[0-9]+}} 326// CHECK: store <4 x float> [[V4]], ptr {{%.*}},27 *A = __builtin_shufflevector( x, mask );28}29 30// CHECK-LABEL: define {{.*}}void @clang_shufflevector_v_v_c(31void clang_shufflevector_v_v_c( float4* A, float4 x, float4 y) {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]], ptr {{%.*}}34 *A = __builtin_shufflevector( x, y, 0, 4, 1, 5 );35}36 37// CHECK-LABEL: define {{.*}}void @clang_shufflevector_v_v_poison(38void clang_shufflevector_v_v_poison( float4* A, float4 x, float4 y) {39// CHECK: [[V:%.*]] = shufflevector <4 x float> {{%.*}}, <4 x float> {{%.*}}, <4 x i32> <i32 0, i32 4, i32 poison, i32 5>40// CHECK: store <4 x float> [[V]], ptr {{%.*}}41 *A = __builtin_shufflevector( x, y, 0, 4, -1, 5 );42}43