1 // REQUIRES: arm-target-arch || armv6m-target-arch
2 // RUN: %clang_builtins %s %librt -o %t && %run %t
13 extern __attribute__((pcs("aapcs"))) void __aeabi_cfcmple(float a
, float b
);
14 extern __attribute__((pcs("aapcs"))) void __aeabi_cfrcmple(float a
, float b
);
16 int test__aeabi_cfcmple(float a
, float b
, int expected
)
18 int32_t cpsr_value
= call_apsr_f(a
, b
, __aeabi_cfcmple
);
19 int32_t r_cpsr_value
= call_apsr_f(b
, a
, __aeabi_cfrcmple
);
21 if (cpsr_value
!= r_cpsr_value
) {
22 printf("error: __aeabi_cfcmple(%f, %f) != __aeabi_cfrcmple(%f, %f)\n", a
, b
, b
, a
);
26 int expected_z
, expected_c
;
30 } else if (expected
== 0) {
34 // a or b is NaN, or a > b
39 union cpsr cpsr
= { .value
= cpsr_value
};
40 if (expected_z
!= cpsr
.flags
.z
|| expected_c
!= cpsr
.flags
.c
) {
41 printf("error in __aeabi_cfcmple(%f, %f) => (Z = %d, C = %d), expected (Z = %d, C = %d)\n",
42 a
, b
, cpsr
.flags
.z
, cpsr
.flags
.c
, expected_z
, expected_c
);
46 cpsr
.value
= r_cpsr_value
;
47 if (expected_z
!= cpsr
.flags
.z
|| expected_c
!= cpsr
.flags
.c
) {
48 printf("error in __aeabi_cfrcmple(%f, %f) => (Z = %d, C = %d), expected (Z = %d, C = %d)\n",
49 a
, b
, cpsr
.flags
.z
, cpsr
.flags
.c
, expected_z
, expected_c
);
59 if (test__aeabi_cfcmple(1.0, 1.0, 0))
61 if (test__aeabi_cfcmple(1234.567, 765.4321, 1))
63 if (test__aeabi_cfcmple(765.4321, 1234.567, -1))
65 if (test__aeabi_cfcmple(-123.0, -678.0, 1))
67 if (test__aeabi_cfcmple(-678.0, -123.0, -1))
69 if (test__aeabi_cfcmple(0.0, -0.0, 0))
71 if (test__aeabi_cfcmple(1.0, NAN
, 1))
73 if (test__aeabi_cfcmple(NAN
, 1.0, 1))
75 if (test__aeabi_cfcmple(NAN
, NAN
, 1))