Commit 6e59e927 authored by Milad Fa's avatar Milad Fa Committed by Commit Bot

AIX: workaround the aix FP glibc bug

Due to a bug on AIX, some of the glibc FP functions do not
preserve the sign bit when a negative input is passed by
value and the output is rounded to 0:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97086

This CL forces the use of "-0.0" in such cases.

Change-Id: If9935596e32e97720f3cb22f27975267ac1124d7
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2468618Reviewed-by: 's avatarZhi An Ng <zhin@chromium.org>
Commit-Queue: Milad Fa <mfarazma@redhat.com>
Cr-Commit-Position: refs/heads/master@{#70512}
parent 36359cc9
......@@ -708,6 +708,19 @@ static inline V ByteReverse(V value) {
}
}
#if V8_OS_AIX
// glibc on aix has a bug when using ceil, trunc or nearbyint:
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97086
template <typename T>
T FpOpWorkaround(T input, T value) {
if (/*if -*/ std::signbit(input) && value == 0.0 &&
/*if +*/ !std::signbit(value)) {
return -0.0;
}
return value;
}
#endif
V8_EXPORT_PRIVATE bool PassesFilter(Vector<const char> name,
Vector<const char> filter);
......
......@@ -405,9 +405,12 @@ template <typename T, T (*float_round_op)(T)>
void simd_float_round_wrapper(Address data) {
constexpr int n = kSimd128Size / sizeof(T);
for (int i = 0; i < n; i++) {
WriteUnalignedValue<T>(
data + (i * sizeof(T)),
float_round_op(ReadUnalignedValue<T>(data + (i * sizeof(T)))));
T input = ReadUnalignedValue<T>(data + (i * sizeof(T)));
T value = float_round_op(input);
#if V8_OS_AIX
value = FpOpWorkaround<T>(input, value);
#endif
WriteUnalignedValue<T>(data + (i * sizeof(T)), value);
}
}
......
......@@ -396,13 +396,6 @@
# TODO(ppc): Implement load/store reverse byte instructions
'test-run-wasm-simd/RunWasm_SimdLoadStoreLoad': [SKIP],
'test-run-wasm-simd/RunWasm_SimdLoadStoreLoad_turbofan': [SKIP],
# TODO(miladfarca): remove once aix gcc bug is fixed.
# gcc on aix has a bug when using ceilf or truncf:
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97086
'test-run-wasm-simd/RunWasm_F32x4Ceil_*': [SKIP],
'test-run-wasm-simd/RunWasm_F32x4Trunc_*': [SKIP],
'test-run-wasm-simd/RunWasm_F64x2Ceil_*': [SKIP],
'test-run-wasm-simd/RunWasm_F64x2Trunc_*': [SKIP],
}], # 'system == aix or (arch == ppc64 and byteorder == big)'
......
......@@ -586,6 +586,9 @@ void RunF32x4UnOpTest(TestExecutionTier execution_tier, LowerSimd lower_simd,
// Extreme values have larger errors so skip them for approximation tests.
if (!exact && IsExtreme(x)) continue;
float expected = expected_op(x);
#if V8_OS_AIX
expected = FpOpWorkaround<float>(x, expected);
#endif
if (!PlatformCanRepresent(expected)) continue;
r.Call(x);
for (int i = 0; i < 4; i++) {
......@@ -1176,6 +1179,9 @@ void RunF64x2UnOpTest(TestExecutionTier execution_tier, LowerSimd lower_simd,
// Extreme values have larger errors so skip them for approximation tests.
if (!exact && IsExtreme(x)) continue;
double expected = expected_op(x);
#if V8_OS_AIX
expected = FpOpWorkaround<double>(x, expected);
#endif
if (!PlatformCanRepresent(expected)) continue;
r.Call(x);
for (int i = 0; i < 2; i++) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment