aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/Float16Test.cpp
diff options
context:
space:
mode:
authorGravatar mtklein <mtklein@chromium.org>2016-08-23 08:58:12 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-08-23 08:58:12 -0700
commita2d2f386000acdc0e10bd38757ece8d6ab78bc25 (patch)
tree9bfccb37425967147d1ea3a374fa4cbbddc89bbd /tests/Float16Test.cpp
parenta97a1ab5719d5c355f7900b7f17dec1e467cf57e (diff)
f16<->f32 ftz is an optional thing for speed.
The ARMv8 asm path actually does it right... that should be okay. My Nexus 5x fails `dm -m _finite_ftz` before this and passes after it. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2276533002 TBR=msarett@google.com Review-Url: https://codereview.chromium.org/2276533002
Diffstat (limited to 'tests/Float16Test.cpp')
-rw-r--r--tests/Float16Test.cpp19
1 files changed, 12 insertions, 7 deletions
diff --git a/tests/Float16Test.cpp b/tests/Float16Test.cpp
index 3e057587c9..99835686fa 100644
--- a/tests/Float16Test.cpp
+++ b/tests/Float16Test.cpp
@@ -70,10 +70,13 @@ DEF_TEST(SkHalfToFloat_finite_ftz, r) {
continue;
}
- // _finite_ftz() flushes denorms to zero. 0.0f will compare == with both +0.0f and -0.0f.
- float expected = is_denorm(h) ? 0.0f : SkHalfToFloat(h);
+ // _finite_ftz() may flush denorms to zero. 0.0f will compare == with both +0.0f and -0.0f.
+ float expected = SkHalfToFloat(h),
+ alternate = is_denorm(h) ? 0.0f : expected;
- REPORTER_ASSERT(r, SkHalfToFloat_finite_ftz(h)[0] == expected);
+ float actual = SkHalfToFloat_finite_ftz(h)[0];
+
+ REPORTER_ASSERT(r, actual == expected || actual == alternate);
}
}
@@ -94,13 +97,15 @@ DEF_TEST(SkFloatToHalf_finite_ftz, r) {
continue;
}
+ uint16_t alternate = expected;
if (is_denorm(expected)) {
- // _finite_ftz() flushes denorms to zero, and happens to keep the sign bit.
- expected = signbit(f) ? 0x8000 : 0x0000;
+ // _finite_ftz() may flush denorms to zero, and happens to keep the sign bit.
+ alternate = signbit(f) ? 0x8000 : 0x0000;
}
uint16_t actual = SkFloatToHalf_finite_ftz(Sk4f{f})[0];
- // _finite_ftz() truncates instead of rounding, so it may be one too small.
- REPORTER_ASSERT(r, actual == expected || actual == expected - 1);
+ // _finite_ftz() may truncate instead of rounding, so it may be one too small.
+ REPORTER_ASSERT(r, actual == expected || actual == expected - 1 ||
+ actual == alternate || actual == alternate - 1);
}
}