xref: /aosp_15_r20/external/clang/test/CodeGen/arm-neon-directed-rounding.c (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li // RUN: %clang_cc1 -triple thumbv8-linux-gnueabihf -target-cpu cortex-a57 -ffreestanding -emit-llvm %s -o - | opt -S -mem2reg | FileCheck %s
2*67e74705SXin Li 
3*67e74705SXin Li #include <arm_neon.h>
4*67e74705SXin Li 
5*67e74705SXin Li // CHECK-LABEL: define <2 x float> @test_vrnda_f32(<2 x float> %a) #0 {
6*67e74705SXin Li // CHECK:   [[TMP0:%.*]] = bitcast <2 x float> %a to <8 x i8>
7*67e74705SXin Li // CHECK:   [[VRNDA_V_I:%.*]] = bitcast <8 x i8> [[TMP0]] to <2 x float>
8*67e74705SXin Li // CHECK:   [[VRNDA_V1_I:%.*]] = call <2 x float> @llvm.arm.neon.vrinta.v2f32(<2 x float> [[VRNDA_V_I]]) #2
9*67e74705SXin Li // CHECK:   [[VRNDA_V2_I:%.*]] = bitcast <2 x float> [[VRNDA_V1_I]] to <8 x i8>
10*67e74705SXin Li // CHECK:   [[TMP1:%.*]] = bitcast <8 x i8> [[VRNDA_V2_I]] to <2 x float>
11*67e74705SXin Li // CHECK:   ret <2 x float> [[TMP1]]
test_vrnda_f32(float32x2_t a)12*67e74705SXin Li float32x2_t test_vrnda_f32(float32x2_t a) {
13*67e74705SXin Li   return vrnda_f32(a);
14*67e74705SXin Li }
15*67e74705SXin Li 
16*67e74705SXin Li // CHECK-LABEL: define <4 x float> @test_vrndaq_f32(<4 x float> %a) #0 {
17*67e74705SXin Li // CHECK:   [[TMP0:%.*]] = bitcast <4 x float> %a to <16 x i8>
18*67e74705SXin Li // CHECK:   [[VRNDAQ_V_I:%.*]] = bitcast <16 x i8> [[TMP0]] to <4 x float>
19*67e74705SXin Li // CHECK:   [[VRNDAQ_V1_I:%.*]] = call <4 x float> @llvm.arm.neon.vrinta.v4f32(<4 x float> [[VRNDAQ_V_I]]) #2
20*67e74705SXin Li // CHECK:   [[VRNDAQ_V2_I:%.*]] = bitcast <4 x float> [[VRNDAQ_V1_I]] to <16 x i8>
21*67e74705SXin Li // CHECK:   [[TMP1:%.*]] = bitcast <16 x i8> [[VRNDAQ_V2_I]] to <4 x float>
22*67e74705SXin Li // CHECK:   ret <4 x float> [[TMP1]]
test_vrndaq_f32(float32x4_t a)23*67e74705SXin Li float32x4_t test_vrndaq_f32(float32x4_t a) {
24*67e74705SXin Li   return vrndaq_f32(a);
25*67e74705SXin Li }
26*67e74705SXin Li 
27*67e74705SXin Li // CHECK-LABEL: define <2 x float> @test_vrndm_f32(<2 x float> %a) #0 {
28*67e74705SXin Li // CHECK:   [[TMP0:%.*]] = bitcast <2 x float> %a to <8 x i8>
29*67e74705SXin Li // CHECK:   [[VRNDM_V_I:%.*]] = bitcast <8 x i8> [[TMP0]] to <2 x float>
30*67e74705SXin Li // CHECK:   [[VRNDM_V1_I:%.*]] = call <2 x float> @llvm.arm.neon.vrintm.v2f32(<2 x float> [[VRNDM_V_I]]) #2
31*67e74705SXin Li // CHECK:   [[VRNDM_V2_I:%.*]] = bitcast <2 x float> [[VRNDM_V1_I]] to <8 x i8>
32*67e74705SXin Li // CHECK:   [[TMP1:%.*]] = bitcast <8 x i8> [[VRNDM_V2_I]] to <2 x float>
33*67e74705SXin Li // CHECK:   ret <2 x float> [[TMP1]]
test_vrndm_f32(float32x2_t a)34*67e74705SXin Li float32x2_t test_vrndm_f32(float32x2_t a) {
35*67e74705SXin Li   return vrndm_f32(a);
36*67e74705SXin Li }
37*67e74705SXin Li 
38*67e74705SXin Li // CHECK-LABEL: define <4 x float> @test_vrndmq_f32(<4 x float> %a) #0 {
39*67e74705SXin Li // CHECK:   [[TMP0:%.*]] = bitcast <4 x float> %a to <16 x i8>
40*67e74705SXin Li // CHECK:   [[VRNDMQ_V_I:%.*]] = bitcast <16 x i8> [[TMP0]] to <4 x float>
41*67e74705SXin Li // CHECK:   [[VRNDMQ_V1_I:%.*]] = call <4 x float> @llvm.arm.neon.vrintm.v4f32(<4 x float> [[VRNDMQ_V_I]]) #2
42*67e74705SXin Li // CHECK:   [[VRNDMQ_V2_I:%.*]] = bitcast <4 x float> [[VRNDMQ_V1_I]] to <16 x i8>
43*67e74705SXin Li // CHECK:   [[TMP1:%.*]] = bitcast <16 x i8> [[VRNDMQ_V2_I]] to <4 x float>
44*67e74705SXin Li // CHECK:   ret <4 x float> [[TMP1]]
test_vrndmq_f32(float32x4_t a)45*67e74705SXin Li float32x4_t test_vrndmq_f32(float32x4_t a) {
46*67e74705SXin Li   return vrndmq_f32(a);
47*67e74705SXin Li }
48*67e74705SXin Li 
49*67e74705SXin Li // CHECK-LABEL: define <2 x float> @test_vrndn_f32(<2 x float> %a) #0 {
50*67e74705SXin Li // CHECK:   [[TMP0:%.*]] = bitcast <2 x float> %a to <8 x i8>
51*67e74705SXin Li // CHECK:   [[VRNDN_V_I:%.*]] = bitcast <8 x i8> [[TMP0]] to <2 x float>
52*67e74705SXin Li // CHECK:   [[VRNDN_V1_I:%.*]] = call <2 x float> @llvm.arm.neon.vrintn.v2f32(<2 x float> [[VRNDN_V_I]]) #2
53*67e74705SXin Li // CHECK:   [[VRNDN_V2_I:%.*]] = bitcast <2 x float> [[VRNDN_V1_I]] to <8 x i8>
54*67e74705SXin Li // CHECK:   [[TMP1:%.*]] = bitcast <8 x i8> [[VRNDN_V2_I]] to <2 x float>
55*67e74705SXin Li // CHECK:   ret <2 x float> [[TMP1]]
test_vrndn_f32(float32x2_t a)56*67e74705SXin Li float32x2_t test_vrndn_f32(float32x2_t a) {
57*67e74705SXin Li   return vrndn_f32(a);
58*67e74705SXin Li }
59*67e74705SXin Li 
60*67e74705SXin Li // CHECK-LABEL: define <4 x float> @test_vrndnq_f32(<4 x float> %a) #0 {
61*67e74705SXin Li // CHECK:   [[TMP0:%.*]] = bitcast <4 x float> %a to <16 x i8>
62*67e74705SXin Li // CHECK:   [[VRNDNQ_V_I:%.*]] = bitcast <16 x i8> [[TMP0]] to <4 x float>
63*67e74705SXin Li // CHECK:   [[VRNDNQ_V1_I:%.*]] = call <4 x float> @llvm.arm.neon.vrintn.v4f32(<4 x float> [[VRNDNQ_V_I]]) #2
64*67e74705SXin Li // CHECK:   [[VRNDNQ_V2_I:%.*]] = bitcast <4 x float> [[VRNDNQ_V1_I]] to <16 x i8>
65*67e74705SXin Li // CHECK:   [[TMP1:%.*]] = bitcast <16 x i8> [[VRNDNQ_V2_I]] to <4 x float>
66*67e74705SXin Li // CHECK:   ret <4 x float> [[TMP1]]
test_vrndnq_f32(float32x4_t a)67*67e74705SXin Li float32x4_t test_vrndnq_f32(float32x4_t a) {
68*67e74705SXin Li   return vrndnq_f32(a);
69*67e74705SXin Li }
70*67e74705SXin Li 
71*67e74705SXin Li // CHECK-LABEL: define <2 x float> @test_vrndp_f32(<2 x float> %a) #0 {
72*67e74705SXin Li // CHECK:   [[TMP0:%.*]] = bitcast <2 x float> %a to <8 x i8>
73*67e74705SXin Li // CHECK:   [[VRNDP_V_I:%.*]] = bitcast <8 x i8> [[TMP0]] to <2 x float>
74*67e74705SXin Li // CHECK:   [[VRNDP_V1_I:%.*]] = call <2 x float> @llvm.arm.neon.vrintp.v2f32(<2 x float> [[VRNDP_V_I]]) #2
75*67e74705SXin Li // CHECK:   [[VRNDP_V2_I:%.*]] = bitcast <2 x float> [[VRNDP_V1_I]] to <8 x i8>
76*67e74705SXin Li // CHECK:   [[TMP1:%.*]] = bitcast <8 x i8> [[VRNDP_V2_I]] to <2 x float>
77*67e74705SXin Li // CHECK:   ret <2 x float> [[TMP1]]
test_vrndp_f32(float32x2_t a)78*67e74705SXin Li float32x2_t test_vrndp_f32(float32x2_t a) {
79*67e74705SXin Li   return vrndp_f32(a);
80*67e74705SXin Li }
81*67e74705SXin Li 
82*67e74705SXin Li // CHECK-LABEL: define <4 x float> @test_vrndpq_f32(<4 x float> %a) #0 {
83*67e74705SXin Li // CHECK:   [[TMP0:%.*]] = bitcast <4 x float> %a to <16 x i8>
84*67e74705SXin Li // CHECK:   [[VRNDPQ_V_I:%.*]] = bitcast <16 x i8> [[TMP0]] to <4 x float>
85*67e74705SXin Li // CHECK:   [[VRNDPQ_V1_I:%.*]] = call <4 x float> @llvm.arm.neon.vrintp.v4f32(<4 x float> [[VRNDPQ_V_I]]) #2
86*67e74705SXin Li // CHECK:   [[VRNDPQ_V2_I:%.*]] = bitcast <4 x float> [[VRNDPQ_V1_I]] to <16 x i8>
87*67e74705SXin Li // CHECK:   [[TMP1:%.*]] = bitcast <16 x i8> [[VRNDPQ_V2_I]] to <4 x float>
88*67e74705SXin Li // CHECK:   ret <4 x float> [[TMP1]]
test_vrndpq_f32(float32x4_t a)89*67e74705SXin Li float32x4_t test_vrndpq_f32(float32x4_t a) {
90*67e74705SXin Li   return vrndpq_f32(a);
91*67e74705SXin Li }
92*67e74705SXin Li 
93*67e74705SXin Li // CHECK-LABEL: define <2 x float> @test_vrndx_f32(<2 x float> %a) #0 {
94*67e74705SXin Li // CHECK:   [[TMP0:%.*]] = bitcast <2 x float> %a to <8 x i8>
95*67e74705SXin Li // CHECK:   [[VRNDX_V_I:%.*]] = bitcast <8 x i8> [[TMP0]] to <2 x float>
96*67e74705SXin Li // CHECK:   [[VRNDX_V1_I:%.*]] = call <2 x float> @llvm.arm.neon.vrintx.v2f32(<2 x float> [[VRNDX_V_I]]) #2
97*67e74705SXin Li // CHECK:   [[VRNDX_V2_I:%.*]] = bitcast <2 x float> [[VRNDX_V1_I]] to <8 x i8>
98*67e74705SXin Li // CHECK:   [[TMP1:%.*]] = bitcast <8 x i8> [[VRNDX_V2_I]] to <2 x float>
99*67e74705SXin Li // CHECK:   ret <2 x float> [[TMP1]]
test_vrndx_f32(float32x2_t a)100*67e74705SXin Li float32x2_t test_vrndx_f32(float32x2_t a) {
101*67e74705SXin Li   return vrndx_f32(a);
102*67e74705SXin Li }
103*67e74705SXin Li 
104*67e74705SXin Li // CHECK-LABEL: define <4 x float> @test_vrndxq_f32(<4 x float> %a) #0 {
105*67e74705SXin Li // CHECK:   [[TMP0:%.*]] = bitcast <4 x float> %a to <16 x i8>
106*67e74705SXin Li // CHECK:   [[VRNDXQ_V_I:%.*]] = bitcast <16 x i8> [[TMP0]] to <4 x float>
107*67e74705SXin Li // CHECK:   [[VRNDXQ_V1_I:%.*]] = call <4 x float> @llvm.arm.neon.vrintx.v4f32(<4 x float> [[VRNDXQ_V_I]]) #2
108*67e74705SXin Li // CHECK:   [[VRNDXQ_V2_I:%.*]] = bitcast <4 x float> [[VRNDXQ_V1_I]] to <16 x i8>
109*67e74705SXin Li // CHECK:   [[TMP1:%.*]] = bitcast <16 x i8> [[VRNDXQ_V2_I]] to <4 x float>
110*67e74705SXin Li // CHECK:   ret <4 x float> [[TMP1]]
test_vrndxq_f32(float32x4_t a)111*67e74705SXin Li float32x4_t test_vrndxq_f32(float32x4_t a) {
112*67e74705SXin Li   return vrndxq_f32(a);
113*67e74705SXin Li }
114*67e74705SXin Li 
115*67e74705SXin Li // CHECK-LABEL: define <2 x float> @test_vrnd_f32(<2 x float> %a) #0 {
116*67e74705SXin Li // CHECK:   [[TMP0:%.*]] = bitcast <2 x float> %a to <8 x i8>
117*67e74705SXin Li // CHECK:   [[VRND_V_I:%.*]] = bitcast <8 x i8> [[TMP0]] to <2 x float>
118*67e74705SXin Li // CHECK:   [[VRND_V1_I:%.*]] = call <2 x float> @llvm.arm.neon.vrintz.v2f32(<2 x float> [[VRND_V_I]]) #2
119*67e74705SXin Li // CHECK:   [[VRND_V2_I:%.*]] = bitcast <2 x float> [[VRND_V1_I]] to <8 x i8>
120*67e74705SXin Li // CHECK:   [[TMP1:%.*]] = bitcast <8 x i8> [[VRND_V2_I]] to <2 x float>
121*67e74705SXin Li // CHECK:   ret <2 x float> [[TMP1]]
test_vrnd_f32(float32x2_t a)122*67e74705SXin Li float32x2_t test_vrnd_f32(float32x2_t a) {
123*67e74705SXin Li   return vrnd_f32(a);
124*67e74705SXin Li }
125*67e74705SXin Li 
126*67e74705SXin Li // CHECK-LABEL: define <4 x float> @test_vrndq_f32(<4 x float> %a) #0 {
127*67e74705SXin Li // CHECK:   [[TMP0:%.*]] = bitcast <4 x float> %a to <16 x i8>
128*67e74705SXin Li // CHECK:   [[VRNDQ_V_I:%.*]] = bitcast <16 x i8> [[TMP0]] to <4 x float>
129*67e74705SXin Li // CHECK:   [[VRNDQ_V1_I:%.*]] = call <4 x float> @llvm.arm.neon.vrintz.v4f32(<4 x float> [[VRNDQ_V_I]]) #2
130*67e74705SXin Li // CHECK:   [[VRNDQ_V2_I:%.*]] = bitcast <4 x float> [[VRNDQ_V1_I]] to <16 x i8>
131*67e74705SXin Li // CHECK:   [[TMP1:%.*]] = bitcast <16 x i8> [[VRNDQ_V2_I]] to <4 x float>
132*67e74705SXin Li // CHECK:   ret <4 x float> [[TMP1]]
test_vrndq_f32(float32x4_t a)133*67e74705SXin Li float32x4_t test_vrndq_f32(float32x4_t a) {
134*67e74705SXin Li   return vrndq_f32(a);
135*67e74705SXin Li }
136