xref: /aosp_15_r20/external/clang/test/CodeGenCXX/vector-splat-conversion.cpp (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li // RUN: %clang_cc1 %s -triple arm64-apple-ios8.1.0 -std=c++11 -emit-llvm -o - | FileCheck %s
2*67e74705SXin Li 
3*67e74705SXin Li typedef __attribute__((__ext_vector_type__(8))) float vector_float8;
4*67e74705SXin Li 
5*67e74705SXin Li typedef vector_float8 float8;
6*67e74705SXin Li 
7*67e74705SXin Li // rdar://20000762
8*67e74705SXin Li // CHECK-LABEL: define void @_Z23MandelbrotPolyCalcSIMD8v
MandelbrotPolyCalcSIMD8()9*67e74705SXin Li void MandelbrotPolyCalcSIMD8() {
10*67e74705SXin Li   constexpr float8 v4 = 4.0;  // value to compare against abs(z)^2, to see if bounded
11*67e74705SXin Li   float8 vABS;
12*67e74705SXin Li   auto vLT  = vABS < v4;
13*67e74705SXin Li   // CHECK: store <8 x float>
14*67e74705SXin Li   // CHECK: [[ZERO:%.*]] = load <8 x float>, <8 x float>* [[VARBS:%.*]]
15*67e74705SXin Li   // CHECK: [[CMP:%.*]] = fcmp olt <8 x float> [[ZERO]]
16*67e74705SXin Li   // CHECK: [[SEXT:%.*]] = sext <8 x i1> [[CMP]] to <8 x i32>
17*67e74705SXin Li   // CHECK: store <8 x i32> [[SEXT]], <8 x i32>* [[VLT:%.*]]
18*67e74705SXin Li }
19*67e74705SXin Li 
20*67e74705SXin Li typedef __attribute__((__ext_vector_type__(4))) int int4;
21*67e74705SXin Li typedef __attribute__((__ext_vector_type__(4))) float float4;
22*67e74705SXin Li typedef __attribute__((__ext_vector_type__(4))) __int128 bigint4;
23*67e74705SXin Li 
24*67e74705SXin Li // CHECK-LABEL: define void @_Z14BoolConversionv
BoolConversion()25*67e74705SXin Li void BoolConversion() {
26*67e74705SXin Li   // CHECK: store <4 x i32> <i32 -1, i32 -1, i32 -1, i32 -1>
27*67e74705SXin Li   int4 intsT = (int4)true;
28*67e74705SXin Li   // CHECK: store <4 x i32> zeroinitializer
29*67e74705SXin Li   int4 intsF = (int4)false;
30*67e74705SXin Li   // CHECK: store <4 x float> <float -1.000000e+00, float -1.000000e+00, float -1.000000e+00, float -1.000000e+00>
31*67e74705SXin Li   float4 floatsT = (float4)true;
32*67e74705SXin Li   // CHECK: store <4 x float> zeroinitializer
33*67e74705SXin Li   float4 floatsF = (float4)false;
34*67e74705SXin Li   // CHECK: store <4 x i128> <i128 -1, i128 -1, i128 -1, i128 -1>
35*67e74705SXin Li   bigint4 bigintsT = (bigint4)true;
36*67e74705SXin Li   // CHECK: store <4 x i128> zeroinitializer
37*67e74705SXin Li   bigint4 bigintsF = (bigint4)false;
38*67e74705SXin Li 
39*67e74705SXin Li   // CHECK: store <4 x i32> <i32 -1, i32 -1, i32 -1, i32 -1>
40*67e74705SXin Li   constexpr int4 cIntsT = (int4)true;
41*67e74705SXin Li   // CHECK: store <4 x i32> zeroinitializer
42*67e74705SXin Li   constexpr int4 cIntsF = (int4)false;
43*67e74705SXin Li   // CHECK: store <4 x float> <float -1.000000e+00, float -1.000000e+00, float -1.000000e+00, float -1.000000e+00>
44*67e74705SXin Li   constexpr float4 cFloatsT = (float4)true;
45*67e74705SXin Li   // CHECK: store <4 x float> zeroinitializer
46*67e74705SXin Li   constexpr float4 cFloatsF = (float4)false;
47*67e74705SXin Li   // CHECK: store <4 x i128> <i128 -1, i128 -1, i128 -1, i128 -1>
48*67e74705SXin Li   constexpr bigint4 cBigintsT = (bigint4)true;
49*67e74705SXin Li   // CHECK: store <4 x i128> zeroinitializer
50*67e74705SXin Li   constexpr bigint4 cBigintsF = (bigint4)false;
51*67e74705SXin Li }
52