aboutsummaryrefslogtreecommitdiff
path: root/math/math_errf.c
diff options
context:
space:
mode:
authorSzabolcs Nagy <szabolcs.nagy@arm.com>2018-06-12 17:18:24 +0100
committerSzabolcs Nagy <szabolcs.nagy@arm.com>2018-06-13 16:32:32 +0100
commit5fa69e1d587a9d86fd54b11568cd3f57b0c3670f (patch)
treeb5b19aa8a7f6f4f675b6396787df61cc9dff0829 /math/math_errf.c
parent21f63567de27880bbc4bf8aa24e3d387c1dfb275 (diff)
downloadarm-optimized-routines-5fa69e1d587a9d86fd54b11568cd3f57b0c3670f.tar.gz
Fix floating-point exceptions with clang
Add optimization barriers to prevent constant folding and code moving transformations. Use opt_barrier_ and force_eval_ consistently to work around fenv semantics breaking optimizations.
Diffstat (limited to 'math/math_errf.c')
-rw-r--r--math/math_errf.c14
1 files changed, 4 insertions, 10 deletions
diff --git a/math/math_errf.c b/math/math_errf.c
index bb38a37..d8f1abc 100644
--- a/math/math_errf.c
+++ b/math/math_errf.c
@@ -33,11 +33,11 @@ with_errnof (float y, int e)
#define with_errnof(x, e) (x)
#endif
-/* NOINLINE prevents fenv semantics breaking optimizations. */
+/* NOINLINE reduces code size. */
NOINLINE static float
xflowf (uint32_t sign, float y)
{
- y = (sign ? -y : y) * y;
+ y = opt_barrier_float (sign ? -y : y) * y;
return with_errnof (y, ERANGE);
}
@@ -63,17 +63,11 @@ __math_oflowf (uint32_t sign)
return xflowf (sign, 0x1p97f);
}
-/* NOINLINE prevents fenv semantics breaking optimizations. */
-NOINLINE static float
-divzerof (float x)
-{
- return with_errnof (x / 0.0f, ERANGE);
-}
-
HIDDEN float
__math_divzerof (uint32_t sign)
{
- return divzerof (sign ? -1.0f : 1.0f);
+ float y = opt_barrier_float (sign ? -1.0f : 1.0f) / 0.0f;
+ return with_errnof (y, ERANGE);
}
HIDDEN float