From 1e114f136895a41397483f4454cf6ce0af1206cd Mon Sep 17 00:00:00 2001 From: Mike Klein Date: Thu, 29 Sep 2016 11:15:15 -0400 Subject: *SkTCast(float*) -> memcpy In some build configurations (I think, GN, GCC 6, Debug) I get a warning that i is used unintialized. This likely has something to do with GCC correctly seeing that the SkTCast construction there is illegal aliasing, and perhaps thus "doesn't happen". Might be that if the SkTCast gets inlined, it decides its implementation is secretly kosher, and so Release builds don't see this. None of this happens with the GCCs we have on the bots... too old? Instead use memcpy() here, which is well defined to do what we intended. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2758 Change-Id: Iaf5c75fbd852193b0b861bf5e71450502511d102 Reviewed-on: https://skia-review.googlesource.com/2758 Commit-Queue: Ben Wagner Reviewed-by: Ben Wagner --- bench/MathBench.cpp | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) (limited to 'bench/MathBench.cpp') diff --git a/bench/MathBench.cpp b/bench/MathBench.cpp index 05a5f8a2d5..541a1052dc 100644 --- a/bench/MathBench.cpp +++ b/bench/MathBench.cpp @@ -126,23 +126,13 @@ private: typedef MathBench INHERITED; }; -static inline float SkFastInvSqrt(float x) { - float xhalf = 0.5f*x; - uint32_t i = *SkTCast(&x); - i = 0x5f3759df - (i>>1); - x = *SkTCast(&i); - x = x*(1.5f-xhalf*x*x); -// x = x*(1.5f-xhalf*x*x); // this line takes err from 10^-3 to 10^-6 - return x; -} - class FastISqrtMathBench : public MathBench { public: FastISqrtMathBench() : INHERITED("fastIsqrt") {} protected: void performTest(float* SK_RESTRICT dst, const float* SK_RESTRICT src, int count) override { for (int i = 0; i < count; ++i) { - dst[i] = SkFastInvSqrt(src[i]); + dst[i] = sk_float_rsqrt(src[i]); } } private: -- cgit v1.2.3