xref: /llvm-project/clang/test/CodeGen/AArch64/neon-misc-constrained.c (revision 207e5ccceec8d3cc3f32723e78f2a142bc61b07d)
1*207e5cccSFangrui Song // RUN: %clang_cc1 -triple arm64-none-linux-gnu -target-feature +neon \
2*207e5cccSFangrui Song // RUN:  -disable-O0-optnone -emit-llvm -o - %s \
3*207e5cccSFangrui Song // RUN: | opt -S -passes=mem2reg | FileCheck --check-prefix=COMMON --check-prefix=COMMONIR --check-prefix=UNCONSTRAINED %s
4*207e5cccSFangrui Song // RUN: %clang_cc1 -triple arm64-none-linux-gnu -target-feature +neon \
5*207e5cccSFangrui Song // RUN:  -ffp-exception-behavior=strict \
6*207e5cccSFangrui Song // RUN:  -disable-O0-optnone -emit-llvm -o - %s \
7*207e5cccSFangrui Song // RUN: | opt -S -passes=mem2reg | FileCheck --check-prefix=COMMON --check-prefix=COMMONIR --check-prefix=CONSTRAINED %s
8*207e5cccSFangrui Song // RUN: %clang_cc1 -triple arm64-none-linux-gnu -target-feature +neon \
9*207e5cccSFangrui Song // RUN:  -disable-O0-optnone -S -o - %s \
10*207e5cccSFangrui Song // RUN: | FileCheck --check-prefix=COMMON --check-prefix=CHECK-ASM %s
11*207e5cccSFangrui Song // RUN: %clang_cc1 -triple arm64-none-linux-gnu -target-feature +neon \
12*207e5cccSFangrui Song // RUN:  -ffp-exception-behavior=strict \
13*207e5cccSFangrui Song // RUN:  -disable-O0-optnone -S -o - %s \
14*207e5cccSFangrui Song // RUN: | FileCheck --check-prefix=COMMON --check-prefix=CHECK-ASM %s
15*207e5cccSFangrui Song 
16*207e5cccSFangrui Song // REQUIRES: aarch64-registered-target
17*207e5cccSFangrui Song 
18*207e5cccSFangrui Song // Test new aarch64 intrinsics and types but constrained
19*207e5cccSFangrui Song 
20*207e5cccSFangrui Song #include <arm_neon.h>
21*207e5cccSFangrui Song 
22*207e5cccSFangrui Song // COMMON-LABEL: test_vrndaq_f64
23*207e5cccSFangrui Song // COMMONIR:   [[TMP0:%.*]] = bitcast <2 x double> %a to <16 x i8>
24*207e5cccSFangrui Song // UNCONSTRAINED: [[VRNDA1_I:%.*]] = call <2 x double> @llvm.round.v2f64(<2 x double> %a)
25*207e5cccSFangrui Song // CONSTRAINED:   [[VRNDA1_I:%.*]] = call <2 x double> @llvm.experimental.constrained.round.v2f64(<2 x double> %a, metadata !"fpexcept.strict")
26*207e5cccSFangrui Song // CHECK-ASM:     frinta v{{[0-9]+}}.2d, v{{[0-9]+}}.2d
27*207e5cccSFangrui Song // COMMONIR:      ret <2 x double> [[VRNDA1_I]]
28*207e5cccSFangrui Song float64x2_t test_vrndaq_f64(float64x2_t a) {
29*207e5cccSFangrui Song   return vrndaq_f64(a);
30*207e5cccSFangrui Song }
31*207e5cccSFangrui Song 
32*207e5cccSFangrui Song // COMMON-LABEL: test_vrndpq_f64
33*207e5cccSFangrui Song // COMMONIR:   [[TMP0:%.*]] = bitcast <2 x double> %a to <16 x i8>
34*207e5cccSFangrui Song // UNCONSTRAINED: [[VRNDP1_I:%.*]] = call <2 x double> @llvm.ceil.v2f64(<2 x double> %a)
35*207e5cccSFangrui Song // CONSTRAINED:   [[VRNDP1_I:%.*]] = call <2 x double> @llvm.experimental.constrained.ceil.v2f64(<2 x double> %a, metadata !"fpexcept.strict")
36*207e5cccSFangrui Song // CHECK-ASM:     frintp v{{[0-9]+}}.2d, v{{[0-9]+}}.2d
37*207e5cccSFangrui Song // COMMONIR:      ret <2 x double> [[VRNDP1_I]]
38*207e5cccSFangrui Song float64x2_t test_vrndpq_f64(float64x2_t a) {
39*207e5cccSFangrui Song   return vrndpq_f64(a);
40*207e5cccSFangrui Song }
41*207e5cccSFangrui Song 
42*207e5cccSFangrui Song // COMMON-LABEL: test_vsqrtq_f32
43*207e5cccSFangrui Song // COMMONIR:   [[TMP0:%.*]] = bitcast <4 x float> %a to <16 x i8>
44*207e5cccSFangrui Song // UNCONSTRAINED: [[VSQRT_I:%.*]] = call <4 x float> @llvm.sqrt.v4f32(<4 x float> %a)
45*207e5cccSFangrui Song // CONSTRAINED:   [[VSQRT_I:%.*]] = call <4 x float> @llvm.experimental.constrained.sqrt.v4f32(<4 x float> %a, metadata !"round.tonearest", metadata !"fpexcept.strict")
46*207e5cccSFangrui Song // CHECK-ASM:     fsqrt v{{[0-9]+}}.4s, v{{[0-9]+}}.4s
47*207e5cccSFangrui Song // COMMONIR:      ret <4 x float> [[VSQRT_I]]
48*207e5cccSFangrui Song float32x4_t test_vsqrtq_f32(float32x4_t a) {
49*207e5cccSFangrui Song   return vsqrtq_f32(a);
50*207e5cccSFangrui Song }
51*207e5cccSFangrui Song 
52*207e5cccSFangrui Song // COMMON-LABEL: test_vsqrtq_f64
53*207e5cccSFangrui Song // COMMONIR:   [[TMP0:%.*]] = bitcast <2 x double> %a to <16 x i8>
54*207e5cccSFangrui Song // UNCONSTRAINED: [[VSQRT_I:%.*]] = call <2 x double> @llvm.sqrt.v2f64(<2 x double> %a)
55*207e5cccSFangrui Song // CONSTRAINED:   [[VSQRT_I:%.*]] = call <2 x double> @llvm.experimental.constrained.sqrt.v2f64(<2 x double> %a, metadata !"round.tonearest", metadata !"fpexcept.strict")
56*207e5cccSFangrui Song // CHECK-ASM:     fsqrt v{{[0-9]+}}.2d, v{{[0-9]+}}.2d
57*207e5cccSFangrui Song // COMMONIR:      ret <2 x double> [[VSQRT_I]]
58*207e5cccSFangrui Song float64x2_t test_vsqrtq_f64(float64x2_t a) {
59*207e5cccSFangrui Song   return vsqrtq_f64(a);
60*207e5cccSFangrui Song }
61