• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // RUN: %clang_cc1 -triple arm64-none-linux-gnu -target-feature +neon \
2 // RUN:   -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s
3 
4 // Test new aarch64 intrinsics and types
5 
6 #include <arm_neon.h>
7 
8 // CHECK-LABEL: define float @test_vcvtxd_f32_f64(double %a) #0 {
9 // CHECK:   [[VCVTXD_F32_F64_I:%.*]] = call float @llvm.aarch64.sisd.fcvtxn(double %a) #2
10 // CHECK:   ret float [[VCVTXD_F32_F64_I]]
test_vcvtxd_f32_f64(float64_t a)11 float32_t test_vcvtxd_f32_f64(float64_t a) {
12   return (float32_t)vcvtxd_f32_f64(a);
13 }
14 
15 // CHECK-LABEL: define i32 @test_vcvtas_s32_f32(float %a) #0 {
16 // CHECK:   [[VCVTAS_S32_F32_I:%.*]] = call i32 @llvm.aarch64.neon.fcvtas.i32.f32(float %a) #2
17 // CHECK:   ret i32 [[VCVTAS_S32_F32_I]]
test_vcvtas_s32_f32(float32_t a)18 int32_t test_vcvtas_s32_f32(float32_t a) {
19   return (int32_t)vcvtas_s32_f32(a);
20 }
21 
22 // CHECK-LABEL: define i64 @test_test_vcvtad_s64_f64(double %a) #0 {
23 // CHECK:   [[VCVTAD_S64_F64_I:%.*]] = call i64 @llvm.aarch64.neon.fcvtas.i64.f64(double %a) #2
24 // CHECK:   ret i64 [[VCVTAD_S64_F64_I]]
test_test_vcvtad_s64_f64(float64_t a)25 int64_t test_test_vcvtad_s64_f64(float64_t a) {
26   return (int64_t)vcvtad_s64_f64(a);
27 }
28 
29 // CHECK-LABEL: define i32 @test_vcvtas_u32_f32(float %a) #0 {
30 // CHECK:   [[VCVTAS_U32_F32_I:%.*]] = call i32 @llvm.aarch64.neon.fcvtau.i32.f32(float %a) #2
31 // CHECK:   ret i32 [[VCVTAS_U32_F32_I]]
test_vcvtas_u32_f32(float32_t a)32 uint32_t test_vcvtas_u32_f32(float32_t a) {
33   return (uint32_t)vcvtas_u32_f32(a);
34 }
35 
36 // CHECK-LABEL: define i64 @test_vcvtad_u64_f64(double %a) #0 {
37 // CHECK:   [[VCVTAD_U64_F64_I:%.*]] = call i64 @llvm.aarch64.neon.fcvtau.i64.f64(double %a) #2
38 // CHECK:   ret i64 [[VCVTAD_U64_F64_I]]
test_vcvtad_u64_f64(float64_t a)39 uint64_t test_vcvtad_u64_f64(float64_t a) {
40   return (uint64_t)vcvtad_u64_f64(a);
41 }
42 
43 // CHECK-LABEL: define i32 @test_vcvtms_s32_f32(float %a) #0 {
44 // CHECK:   [[VCVTMS_S32_F32_I:%.*]] = call i32 @llvm.aarch64.neon.fcvtms.i32.f32(float %a) #2
45 // CHECK:   ret i32 [[VCVTMS_S32_F32_I]]
test_vcvtms_s32_f32(float32_t a)46 int32_t test_vcvtms_s32_f32(float32_t a) {
47   return (int32_t)vcvtms_s32_f32(a);
48 }
49 
50 // CHECK-LABEL: define i64 @test_vcvtmd_s64_f64(double %a) #0 {
51 // CHECK:   [[VCVTMD_S64_F64_I:%.*]] = call i64 @llvm.aarch64.neon.fcvtms.i64.f64(double %a) #2
52 // CHECK:   ret i64 [[VCVTMD_S64_F64_I]]
test_vcvtmd_s64_f64(float64_t a)53 int64_t test_vcvtmd_s64_f64(float64_t a) {
54   return (int64_t)vcvtmd_s64_f64(a);
55 }
56 
57 // CHECK-LABEL: define i32 @test_vcvtms_u32_f32(float %a) #0 {
58 // CHECK:   [[VCVTMS_U32_F32_I:%.*]] = call i32 @llvm.aarch64.neon.fcvtmu.i32.f32(float %a) #2
59 // CHECK:   ret i32 [[VCVTMS_U32_F32_I]]
test_vcvtms_u32_f32(float32_t a)60 uint32_t test_vcvtms_u32_f32(float32_t a) {
61   return (uint32_t)vcvtms_u32_f32(a);
62 }
63 
64 // CHECK-LABEL: define i64 @test_vcvtmd_u64_f64(double %a) #0 {
65 // CHECK:   [[VCVTMD_U64_F64_I:%.*]] = call i64 @llvm.aarch64.neon.fcvtmu.i64.f64(double %a) #2
66 // CHECK:   ret i64 [[VCVTMD_U64_F64_I]]
test_vcvtmd_u64_f64(float64_t a)67 uint64_t test_vcvtmd_u64_f64(float64_t a) {
68   return (uint64_t)vcvtmd_u64_f64(a);
69 }
70 
71 // CHECK-LABEL: define i32 @test_vcvtns_s32_f32(float %a) #0 {
72 // CHECK:   [[VCVTNS_S32_F32_I:%.*]] = call i32 @llvm.aarch64.neon.fcvtns.i32.f32(float %a) #2
73 // CHECK:   ret i32 [[VCVTNS_S32_F32_I]]
test_vcvtns_s32_f32(float32_t a)74 int32_t test_vcvtns_s32_f32(float32_t a) {
75   return (int32_t)vcvtns_s32_f32(a);
76 }
77 
78 // CHECK-LABEL: define i64 @test_vcvtnd_s64_f64(double %a) #0 {
79 // CHECK:   [[VCVTND_S64_F64_I:%.*]] = call i64 @llvm.aarch64.neon.fcvtns.i64.f64(double %a) #2
80 // CHECK:   ret i64 [[VCVTND_S64_F64_I]]
test_vcvtnd_s64_f64(float64_t a)81 int64_t test_vcvtnd_s64_f64(float64_t a) {
82   return (int64_t)vcvtnd_s64_f64(a);
83 }
84 
85 // CHECK-LABEL: define i32 @test_vcvtns_u32_f32(float %a) #0 {
86 // CHECK:   [[VCVTNS_U32_F32_I:%.*]] = call i32 @llvm.aarch64.neon.fcvtnu.i32.f32(float %a) #2
87 // CHECK:   ret i32 [[VCVTNS_U32_F32_I]]
test_vcvtns_u32_f32(float32_t a)88 uint32_t test_vcvtns_u32_f32(float32_t a) {
89   return (uint32_t)vcvtns_u32_f32(a);
90 }
91 
92 // CHECK-LABEL: define i64 @test_vcvtnd_u64_f64(double %a) #0 {
93 // CHECK:   [[VCVTND_U64_F64_I:%.*]] = call i64 @llvm.aarch64.neon.fcvtnu.i64.f64(double %a) #2
94 // CHECK:   ret i64 [[VCVTND_U64_F64_I]]
test_vcvtnd_u64_f64(float64_t a)95 uint64_t test_vcvtnd_u64_f64(float64_t a) {
96   return (uint64_t)vcvtnd_u64_f64(a);
97 }
98 
99 // CHECK-LABEL: define i32 @test_vcvtps_s32_f32(float %a) #0 {
100 // CHECK:   [[VCVTPS_S32_F32_I:%.*]] = call i32 @llvm.aarch64.neon.fcvtps.i32.f32(float %a) #2
101 // CHECK:   ret i32 [[VCVTPS_S32_F32_I]]
test_vcvtps_s32_f32(float32_t a)102 int32_t test_vcvtps_s32_f32(float32_t a) {
103   return (int32_t)vcvtps_s32_f32(a);
104 }
105 
106 // CHECK-LABEL: define i64 @test_vcvtpd_s64_f64(double %a) #0 {
107 // CHECK:   [[VCVTPD_S64_F64_I:%.*]] = call i64 @llvm.aarch64.neon.fcvtps.i64.f64(double %a) #2
108 // CHECK:   ret i64 [[VCVTPD_S64_F64_I]]
test_vcvtpd_s64_f64(float64_t a)109 int64_t test_vcvtpd_s64_f64(float64_t a) {
110   return (int64_t)vcvtpd_s64_f64(a);
111 }
112 
113 // CHECK-LABEL: define i32 @test_vcvtps_u32_f32(float %a) #0 {
114 // CHECK:   [[VCVTPS_U32_F32_I:%.*]] = call i32 @llvm.aarch64.neon.fcvtpu.i32.f32(float %a) #2
115 // CHECK:   ret i32 [[VCVTPS_U32_F32_I]]
test_vcvtps_u32_f32(float32_t a)116 uint32_t test_vcvtps_u32_f32(float32_t a) {
117   return (uint32_t)vcvtps_u32_f32(a);
118 }
119 
120 // CHECK-LABEL: define i64 @test_vcvtpd_u64_f64(double %a) #0 {
121 // CHECK:   [[VCVTPD_U64_F64_I:%.*]] = call i64 @llvm.aarch64.neon.fcvtpu.i64.f64(double %a) #2
122 // CHECK:   ret i64 [[VCVTPD_U64_F64_I]]
test_vcvtpd_u64_f64(float64_t a)123 uint64_t test_vcvtpd_u64_f64(float64_t a) {
124   return (uint64_t)vcvtpd_u64_f64(a);
125 }
126 
127 // CHECK-LABEL: define i32 @test_vcvts_s32_f32(float %a) #0 {
128 // CHECK:   [[TMP0:%.*]] = fptosi float %a to i32
129 // CHECK:   ret i32 [[TMP0]]
test_vcvts_s32_f32(float32_t a)130 int32_t test_vcvts_s32_f32(float32_t a) {
131   return (int32_t)vcvts_s32_f32(a);
132 }
133 
134 // CHECK-LABEL: define i64 @test_vcvtd_s64_f64(double %a) #0 {
135 // CHECK:   [[TMP0:%.*]] = fptosi double %a to i64
136 // CHECK:   ret i64 [[TMP0]]
test_vcvtd_s64_f64(float64_t a)137 int64_t test_vcvtd_s64_f64(float64_t a) {
138   return (int64_t)vcvtd_s64_f64(a);
139 }
140 
141 // CHECK-LABEL: define i32 @test_vcvts_u32_f32(float %a) #0 {
142 // CHECK:   [[TMP0:%.*]] = fptoui float %a to i32
143 // CHECK:   ret i32 [[TMP0]]
test_vcvts_u32_f32(float32_t a)144 uint32_t test_vcvts_u32_f32(float32_t a) {
145   return (uint32_t)vcvts_u32_f32(a);
146 }
147 
148 // CHECK-LABEL: define i64 @test_vcvtd_u64_f64(double %a) #0 {
149 // CHECK:   [[TMP0:%.*]] = fptoui double %a to i64
150 // CHECK:   ret i64 [[TMP0]]
test_vcvtd_u64_f64(float64_t a)151 uint64_t test_vcvtd_u64_f64(float64_t a) {
152   return (uint64_t)vcvtd_u64_f64(a);
153 }
154