xref: /minix3/external/bsd/llvm/dist/clang/test/CodeGen/builtins-ppc-vsx.c (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc // REQUIRES: powerpc-registered-target
2*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -faltivec -target-feature +vsx -triple powerpc64-unknown-unknown -emit-llvm %s -o - | FileCheck %s
3*0a6a1f1dSLionel Sambuc 
4*0a6a1f1dSLionel Sambuc vector unsigned char vuc = { 8,  9, 10, 11, 12, 13, 14, 15,
5*0a6a1f1dSLionel Sambuc                              0,  1,  2,  3,  4,  5,  6,  7};
6*0a6a1f1dSLionel Sambuc vector float vf = { -1.5, 2.5, -3.5, 4.5 };
7*0a6a1f1dSLionel Sambuc vector double vd = { 3.5, -7.5 };
8*0a6a1f1dSLionel Sambuc vector signed int vsi = { -1, 2, -3, 4 };
9*0a6a1f1dSLionel Sambuc vector unsigned int vui = { 0, 1, 2, 3 };
10*0a6a1f1dSLionel Sambuc vector signed long long vsll = { 255LL, -937LL };
11*0a6a1f1dSLionel Sambuc vector unsigned long long vull = { 1447LL, 2894LL };
12*0a6a1f1dSLionel Sambuc double d = 23.4;
13*0a6a1f1dSLionel Sambuc 
14*0a6a1f1dSLionel Sambuc vector float res_vf;
15*0a6a1f1dSLionel Sambuc vector double res_vd;
16*0a6a1f1dSLionel Sambuc vector signed int res_vsi;
17*0a6a1f1dSLionel Sambuc vector unsigned int res_vui;
18*0a6a1f1dSLionel Sambuc vector signed long long res_vsll;
19*0a6a1f1dSLionel Sambuc vector unsigned long long res_vull;
20*0a6a1f1dSLionel Sambuc double res_d;
21*0a6a1f1dSLionel Sambuc 
test1()22*0a6a1f1dSLionel Sambuc void test1() {
23*0a6a1f1dSLionel Sambuc // CHECK-LABEL: define void @test1
24*0a6a1f1dSLionel Sambuc 
25*0a6a1f1dSLionel Sambuc   /* vec_div */
26*0a6a1f1dSLionel Sambuc   res_vf = vec_div(vf, vf);
27*0a6a1f1dSLionel Sambuc // CHECK: @llvm.ppc.vsx.xvdivsp
28*0a6a1f1dSLionel Sambuc 
29*0a6a1f1dSLionel Sambuc   res_vd = vec_div(vd, vd);
30*0a6a1f1dSLionel Sambuc // CHECK: @llvm.ppc.vsx.xvdivdp
31*0a6a1f1dSLionel Sambuc 
32*0a6a1f1dSLionel Sambuc   /* vec_max */
33*0a6a1f1dSLionel Sambuc   res_vf = vec_max(vf, vf);
34*0a6a1f1dSLionel Sambuc // CHECK: @llvm.ppc.vsx.xvmaxsp
35*0a6a1f1dSLionel Sambuc 
36*0a6a1f1dSLionel Sambuc   res_vd = vec_max(vd, vd);
37*0a6a1f1dSLionel Sambuc // CHECK: @llvm.ppc.vsx.xvmaxdp
38*0a6a1f1dSLionel Sambuc 
39*0a6a1f1dSLionel Sambuc   res_vf = vec_vmaxfp(vf, vf);
40*0a6a1f1dSLionel Sambuc // CHECK: @llvm.ppc.vsx.xvmaxsp
41*0a6a1f1dSLionel Sambuc 
42*0a6a1f1dSLionel Sambuc   /* vec_min */
43*0a6a1f1dSLionel Sambuc   res_vf = vec_min(vf, vf);
44*0a6a1f1dSLionel Sambuc // CHECK: @llvm.ppc.vsx.xvminsp
45*0a6a1f1dSLionel Sambuc 
46*0a6a1f1dSLionel Sambuc   res_vd = vec_min(vd, vd);
47*0a6a1f1dSLionel Sambuc // CHECK: @llvm.ppc.vsx.xvmindp
48*0a6a1f1dSLionel Sambuc 
49*0a6a1f1dSLionel Sambuc   res_vf = vec_vminfp(vf, vf);
50*0a6a1f1dSLionel Sambuc // CHECK: @llvm.ppc.vsx.xvminsp
51*0a6a1f1dSLionel Sambuc 
52*0a6a1f1dSLionel Sambuc   res_d = __builtin_vsx_xsmaxdp(d, d);
53*0a6a1f1dSLionel Sambuc // CHECK: @llvm.ppc.vsx.xsmaxdp
54*0a6a1f1dSLionel Sambuc 
55*0a6a1f1dSLionel Sambuc   res_d = __builtin_vsx_xsmindp(d, d);
56*0a6a1f1dSLionel Sambuc // CHECK: @llvm.ppc.vsx.xsmindp
57*0a6a1f1dSLionel Sambuc 
58*0a6a1f1dSLionel Sambuc   /* vec_perm */
59*0a6a1f1dSLionel Sambuc   res_vsll = vec_perm(vsll, vsll, vuc);
60*0a6a1f1dSLionel Sambuc // CHECK: @llvm.ppc.altivec.vperm
61*0a6a1f1dSLionel Sambuc 
62*0a6a1f1dSLionel Sambuc   res_vull = vec_perm(vull, vull, vuc);
63*0a6a1f1dSLionel Sambuc // CHECK: @llvm.ppc.altivec.vperm
64*0a6a1f1dSLionel Sambuc 
65*0a6a1f1dSLionel Sambuc   res_vd = vec_perm(vd, vd, vuc);
66*0a6a1f1dSLionel Sambuc // CHECK: @llvm.ppc.altivec.vperm
67*0a6a1f1dSLionel Sambuc 
68*0a6a1f1dSLionel Sambuc   res_vsll = vec_vperm(vsll, vsll, vuc);
69*0a6a1f1dSLionel Sambuc // CHECK: @llvm.ppc.altivec.vperm
70*0a6a1f1dSLionel Sambuc 
71*0a6a1f1dSLionel Sambuc   res_vull = vec_vperm(vull, vull, vuc);
72*0a6a1f1dSLionel Sambuc // CHECK: @llvm.ppc.altivec.vperm
73*0a6a1f1dSLionel Sambuc 
74*0a6a1f1dSLionel Sambuc   res_vd = vec_vperm(vd, vd, vuc);
75*0a6a1f1dSLionel Sambuc // CHECK: @llvm.ppc.altivec.vperm
76*0a6a1f1dSLionel Sambuc 
77*0a6a1f1dSLionel Sambuc   /* vec_vsx_ld */
78*0a6a1f1dSLionel Sambuc 
79*0a6a1f1dSLionel Sambuc   res_vsi = vec_vsx_ld(0, &vsi);
80*0a6a1f1dSLionel Sambuc // CHECK: @llvm.ppc.vsx.lxvw4x
81*0a6a1f1dSLionel Sambuc 
82*0a6a1f1dSLionel Sambuc   res_vui = vec_vsx_ld(0, &vui);
83*0a6a1f1dSLionel Sambuc // CHECK: @llvm.ppc.vsx.lxvw4x
84*0a6a1f1dSLionel Sambuc 
85*0a6a1f1dSLionel Sambuc   res_vf = vec_vsx_ld (0, &vf);
86*0a6a1f1dSLionel Sambuc // CHECK: @llvm.ppc.vsx.lxvw4x
87*0a6a1f1dSLionel Sambuc 
88*0a6a1f1dSLionel Sambuc   res_vsll = vec_vsx_ld(0, &vsll);
89*0a6a1f1dSLionel Sambuc // CHECK: @llvm.ppc.vsx.lxvd2x
90*0a6a1f1dSLionel Sambuc 
91*0a6a1f1dSLionel Sambuc   res_vull = vec_vsx_ld(0, &vull);
92*0a6a1f1dSLionel Sambuc // CHECK: @llvm.ppc.vsx.lxvd2x
93*0a6a1f1dSLionel Sambuc 
94*0a6a1f1dSLionel Sambuc   res_vd = vec_vsx_ld(0, &vd);
95*0a6a1f1dSLionel Sambuc // CHECK: @llvm.ppc.vsx.lxvd2x
96*0a6a1f1dSLionel Sambuc 
97*0a6a1f1dSLionel Sambuc   /* vec_vsx_st */
98*0a6a1f1dSLionel Sambuc 
99*0a6a1f1dSLionel Sambuc   vec_vsx_st(vsi, 0, &res_vsi);
100*0a6a1f1dSLionel Sambuc // CHECK: @llvm.ppc.vsx.stxvw4x
101*0a6a1f1dSLionel Sambuc 
102*0a6a1f1dSLionel Sambuc   vec_vsx_st(vui, 0, &res_vui);
103*0a6a1f1dSLionel Sambuc // CHECK: @llvm.ppc.vsx.stxvw4x
104*0a6a1f1dSLionel Sambuc 
105*0a6a1f1dSLionel Sambuc   vec_vsx_st(vf, 0, &res_vf);
106*0a6a1f1dSLionel Sambuc // CHECK: @llvm.ppc.vsx.stxvw4x
107*0a6a1f1dSLionel Sambuc 
108*0a6a1f1dSLionel Sambuc   vec_vsx_st(vsll, 0, &res_vsll);
109*0a6a1f1dSLionel Sambuc // CHECK: @llvm.ppc.vsx.stxvd2x
110*0a6a1f1dSLionel Sambuc 
111*0a6a1f1dSLionel Sambuc   vec_vsx_st(vull, 0, &res_vull);
112*0a6a1f1dSLionel Sambuc // CHECK: @llvm.ppc.vsx.stxvd2x
113*0a6a1f1dSLionel Sambuc 
114*0a6a1f1dSLionel Sambuc   vec_vsx_st(vd, 0, &res_vd);
115*0a6a1f1dSLionel Sambuc // CHECK: @llvm.ppc.vsx.stxvd2x
116*0a6a1f1dSLionel Sambuc }
117