Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / CodeGen / SystemZ / builtins-systemz-vector2.c
blob0fcfeeafbfaa6aded89b1a7bf9847dbaac8b8eab
1 // REQUIRES: systemz-registered-target
2 // RUN: %clang_cc1 -target-cpu z14 -triple s390x-ibm-linux -flax-vector-conversions=none \
3 // RUN: -Wall -Wno-unused -Werror -emit-llvm %s -o - | FileCheck %s
5 typedef __attribute__((vector_size(16))) signed char vec_schar;
6 typedef __attribute__((vector_size(16))) signed short vec_sshort;
7 typedef __attribute__((vector_size(16))) signed int vec_sint;
8 typedef __attribute__((vector_size(16))) signed long long vec_slong;
9 typedef __attribute__((vector_size(16))) unsigned char vec_uchar;
10 typedef __attribute__((vector_size(16))) unsigned short vec_ushort;
11 typedef __attribute__((vector_size(16))) unsigned int vec_uint;
12 typedef __attribute__((vector_size(16))) unsigned long long vec_ulong;
13 typedef __attribute__((vector_size(16))) double vec_double;
14 typedef __attribute__((vector_size(16))) float vec_float;
16 volatile vec_schar vsc;
17 volatile vec_sshort vss;
18 volatile vec_sint vsi;
19 volatile vec_slong vsl;
20 volatile vec_uchar vuc;
21 volatile vec_ushort vus;
22 volatile vec_uint vui;
23 volatile vec_ulong vul;
24 volatile vec_double vd;
25 volatile vec_float vf;
27 volatile unsigned int len;
28 const void * volatile cptr;
29 void * volatile ptr;
30 int cc;
32 void test_core(void) {
33 vul = __builtin_s390_vbperm(vuc, vuc);
34 // CHECK: call <2 x i64> @llvm.s390.vbperm(<16 x i8> %{{.*}}, <16 x i8> %{{.*}})
36 vsc = __builtin_s390_vlrl(len, cptr);
37 // CHECK: call <16 x i8> @llvm.s390.vlrl(i32 %{{.*}}, ptr %{{.*}})
39 __builtin_s390_vstrl(vsc, len, ptr);
40 // CHECK: call void @llvm.s390.vstrl(<16 x i8> %{{.*}}, i32 %{{.*}}, ptr %{{.*}})
43 void test_integer(void) {
44 vuc = __builtin_s390_vmslg(vul, vul, vuc, 0);
45 // CHECK: call <16 x i8> @llvm.s390.vmslg(<2 x i64> %{{.*}}, <2 x i64> %{{.*}}, <16 x i8> %{{.*}}, i32 0)
46 vuc = __builtin_s390_vmslg(vul, vul, vuc, 15);
47 // CHECK: call <16 x i8> @llvm.s390.vmslg(<2 x i64> %{{.*}}, <2 x i64> %{{.*}}, <16 x i8> %{{.*}}, i32 15)
50 void test_float(void) {
51 vd = __builtin_s390_vfmaxdb(vd, vd, 4);
52 // CHECK: call <2 x double> @llvm.maxnum.v2f64(<2 x double> %{{.*}}, <2 x double> %{{.*}})
53 vd = __builtin_s390_vfmaxdb(vd, vd, 0);
54 // CHECK: call <2 x double> @llvm.s390.vfmaxdb(<2 x double> %{{.*}}, <2 x double> %{{.*}}, i32 0)
55 vd = __builtin_s390_vfmaxdb(vd, vd, 15);
56 // CHECK: call <2 x double> @llvm.s390.vfmaxdb(<2 x double> %{{.*}}, <2 x double> %{{.*}}, i32 15)
58 vd = __builtin_s390_vfmindb(vd, vd, 4);
59 // CHECK: call <2 x double> @llvm.minnum.v2f64(<2 x double> %{{.*}}, <2 x double> %{{.*}})
60 vd = __builtin_s390_vfmindb(vd, vd, 0);
61 // CHECK: call <2 x double> @llvm.s390.vfmindb(<2 x double> %{{.*}}, <2 x double> %{{.*}}, i32 0)
62 vd = __builtin_s390_vfmindb(vd, vd, 15);
63 // CHECK: call <2 x double> @llvm.s390.vfmindb(<2 x double> %{{.*}}, <2 x double> %{{.*}}, i32 15)
65 vd = __builtin_s390_vfnmadb(vd, vd, vd);
66 // CHECK: [[RES:%[^ ]+]] = call <2 x double> @llvm.fma.v2f64(<2 x double> %{{.*}}, <2 x double> %{{.*}}, <2 x double> %{{.*}})
67 // CHECK: fneg <2 x double> [[RES]]
68 vd = __builtin_s390_vfnmsdb(vd, vd, vd);
69 // CHECK: [[NEG:%[^ ]+]] = fneg <2 x double> %{{.*}}
70 // CHECK: [[RES:%[^ ]+]] = call <2 x double> @llvm.fma.v2f64(<2 x double> %{{.*}}, <2 x double> %{{.*}}, <2 x double> [[NEG]])
71 // CHECK: fneg <2 x double> [[RES]]
73 vsi = __builtin_s390_vfcesbs(vf, vf, &cc);
74 // CHECK: call { <4 x i32>, i32 } @llvm.s390.vfcesbs(<4 x float> %{{.*}}, <4 x float> %{{.*}})
75 vsi = __builtin_s390_vfchsbs(vf, vf, &cc);
76 // CHECK: call { <4 x i32>, i32 } @llvm.s390.vfchsbs(<4 x float> %{{.*}}, <4 x float> %{{.*}})
77 vsi = __builtin_s390_vfchesbs(vf, vf, &cc);
78 // CHECK: call { <4 x i32>, i32 } @llvm.s390.vfchesbs(<4 x float> %{{.*}}, <4 x float> %{{.*}})
80 vsi = __builtin_s390_vftcisb(vf, 0, &cc);
81 // CHECK: call { <4 x i32>, i32 } @llvm.s390.vftcisb(<4 x float> %{{.*}}, i32 0)
82 vsi = __builtin_s390_vftcisb(vf, 4095, &cc);
83 // CHECK: call { <4 x i32>, i32 } @llvm.s390.vftcisb(<4 x float> %{{.*}}, i32 4095)
85 vf = __builtin_s390_vfmaxsb(vf, vf, 4);
86 // CHECK: call <4 x float> @llvm.maxnum.v4f32(<4 x float> %{{.*}}, <4 x float> %{{.*}})
87 vf = __builtin_s390_vfmaxsb(vf, vf, 0);
88 // CHECK: call <4 x float> @llvm.s390.vfmaxsb(<4 x float> %{{.*}}, <4 x float> %{{.*}}, i32 0)
89 vf = __builtin_s390_vfmaxsb(vf, vf, 15);
90 // CHECK: call <4 x float> @llvm.s390.vfmaxsb(<4 x float> %{{.*}}, <4 x float> %{{.*}}, i32 15)
92 vf = __builtin_s390_vfminsb(vf, vf, 4);
93 // CHECK: call <4 x float> @llvm.minnum.v4f32(<4 x float> %{{.*}}, <4 x float> %{{.*}})
94 vf = __builtin_s390_vfminsb(vf, vf, 0);
95 // CHECK: call <4 x float> @llvm.s390.vfminsb(<4 x float> %{{.*}}, <4 x float> %{{.*}}, i32 0)
96 vf = __builtin_s390_vfminsb(vf, vf, 15);
97 // CHECK: call <4 x float> @llvm.s390.vfminsb(<4 x float> %{{.*}}, <4 x float> %{{.*}}, i32 15)
99 vf = __builtin_s390_vfsqsb(vf);
100 // CHECK: call <4 x float> @llvm.sqrt.v4f32(<4 x float> %{{.*}})
102 vf = __builtin_s390_vfmasb(vf, vf, vf);
103 // CHECK: call <4 x float> @llvm.fma.v4f32(<4 x float> %{{.*}}, <4 x float> %{{.*}}, <4 x float> %{{.*}})
104 vf = __builtin_s390_vfmssb(vf, vf, vf);
105 // CHECK: [[NEG:%[^ ]+]] = fneg <4 x float> %{{.*}}
106 // CHECK: call <4 x float> @llvm.fma.v4f32(<4 x float> %{{.*}}, <4 x float> %{{.*}}, <4 x float> [[NEG]])
107 vf = __builtin_s390_vfnmasb(vf, vf, vf);
108 // CHECK: [[RES:%[^ ]+]] = call <4 x float> @llvm.fma.v4f32(<4 x float> %{{.*}}, <4 x float> %{{.*}}, <4 x float> %{{.*}})
109 // CHECK: fneg <4 x float> [[RES]]
110 vf = __builtin_s390_vfnmssb(vf, vf, vf);
111 // CHECK: [[NEG:%[^ ]+]] = fneg <4 x float> %{{.*}}
112 // CHECK: [[RES:%[^ ]+]] = call <4 x float> @llvm.fma.v4f32(<4 x float> %{{.*}}, <4 x float> %{{.*}}, <4 x float> [[NEG]])
113 // CHECK: fneg <4 x float> [[RES]]
115 vf = __builtin_s390_vflpsb(vf);
116 // CHECK: call <4 x float> @llvm.fabs.v4f32(<4 x float> %{{.*}})
117 vf = __builtin_s390_vflnsb(vf);
118 // CHECK: [[ABS:%[^ ]+]] = call <4 x float> @llvm.fabs.v4f32(<4 x float> %{{.*}})
119 // CHECK: fneg <4 x float> [[ABS]]
121 vf = __builtin_s390_vfisb(vf, 0, 0);
122 // CHECK: call <4 x float> @llvm.rint.v4f32(<4 x float> %{{.*}})
123 vf = __builtin_s390_vfisb(vf, 4, 0);
124 // CHECK: call <4 x float> @llvm.nearbyint.v4f32(<4 x float> %{{.*}})
125 vf = __builtin_s390_vfisb(vf, 4, 1);
126 // CHECK: call <4 x float> @llvm.round.v4f32(<4 x float> %{{.*}})
127 vf = __builtin_s390_vfisb(vf, 4, 5);
128 // CHECK: call <4 x float> @llvm.trunc.v4f32(<4 x float> %{{.*}})
129 vf = __builtin_s390_vfisb(vf, 4, 6);
130 // CHECK: call <4 x float> @llvm.ceil.v4f32(<4 x float> %{{.*}})
131 vf = __builtin_s390_vfisb(vf, 4, 7);
132 // CHECK: call <4 x float> @llvm.floor.v4f32(<4 x float> %{{.*}})
133 vf = __builtin_s390_vfisb(vf, 4, 4);
134 // CHECK: call <4 x float> @llvm.s390.vfisb(<4 x float> %{{.*}}, i32 4, i32 4)