diff options
author | Georgios Pinitas <georgios.pinitas@arm.com> | 2017-07-03 14:38:50 +0100 |
---|---|---|
committer | Anthony Barbier <anthony.barbier@arm.com> | 2018-09-17 14:15:39 +0100 |
commit | 6410fb2a14427713251f5d97144ac5d4f17c988c (patch) | |
tree | 7f5c4e6f4a197a7510dbd19aeee13d2db7252167 /tests/validation/FixedPoint.h | |
parent | f0dea703ce3e2b465e79298bca95c4952a60f608 (diff) | |
download | ComputeLibrary-6410fb2a14427713251f5d97144ac5d4f17c988c.tar.gz |
COMPMID-417: Revert invsqrt validation implementation.
Change-Id: I7da949aaddef8cbd25b3d05727839b7b82b08eb5
Reviewed-on: http://mpd-gerrit.cambridge.arm.com/79530
Tested-by: Kaizen <jeremy.johnson+kaizengerrit@arm.com>
Reviewed-by: Moritz Pflanzer <moritz.pflanzer@arm.com>
Diffstat (limited to 'tests/validation/FixedPoint.h')
-rw-r--r-- | tests/validation/FixedPoint.h | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/tests/validation/FixedPoint.h b/tests/validation/FixedPoint.h index dca6e7ed2f..53f532cd8c 100644 --- a/tests/validation/FixedPoint.h +++ b/tests/validation/FixedPoint.h @@ -753,18 +753,22 @@ struct functions shift += std::numeric_limits<T>::is_signed ? 1 : 0; - const auto three_half = fixed_point<T>(1.5f, p); - fixed_point<T> a = shift < 0 ? shift_left(x, -shift) : shift_right(x, shift); - const fixed_point<T> x_half = shift_right(a, 1); + // Use volatile to restrict compiler optimizations on shift as compiler reports maybe-uninitialized error on Android + volatile int8_t *shift_ptr = &shift; + + auto const_three = fixed_point<T>(3, p); + auto a = (*shift_ptr < 0) ? shift_left(x, -(shift)) : shift_right(x, shift); + fixed_point<T> x2 = a; // We need three iterations to find the result for QS8 and five for QS16 constexpr int num_iterations = std::is_same<T, int8_t>::value ? 3 : 5; for(int i = 0; i < num_iterations; ++i) { - a = mul(a, sub(three_half, mul(x_half, mul(a, a)))); + fixed_point<T> three_minus_dx = sub(const_three, mul(a, mul(x2, x2))); + x2 = shift_right(mul(x2, three_minus_dx), 1); } - return (shift < 0) ? shift_left(a, -shift >> 1) : shift_right(a, shift >> 1); + return (shift < 0) ? shift_left(x2, -shift >> 1) : shift_right(x2, shift >> 1); } /** Calculate the hyperbolic tangent of a fixed point number * |