Fix division by zero in radial gradiants with NEON

The NEON implementation uses rsqrt and thus can not be taken on 0, so
replace the minimum with something close to zero instead of zero.

Task-number: QTBUG-59961
Change-Id: Ia39e45be675b056c1e22900495ce9ba4e8b70e5f
Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
bb10
Allan Sandfeld Jensen 2018-04-23 15:09:35 +02:00
parent 143cf9e467
commit e413874467
2 changed files with 5 additions and 4 deletions

View File

@ -520,7 +520,12 @@ public:
const typename Simd::Float32x4 v_r0 = Simd::v_dup(data->gradient.radial.focal.radius);
const typename Simd::Float32x4 v_dr = Simd::v_dup(op->radial.dr);
#if defined(__ARM_NEON__)
// NEON doesn't have SIMD sqrt, but uses rsqrt instead that can't be taken of 0.
const typename Simd::Float32x4 v_min = Simd::v_dup(std::numeric_limits<float>::epsilon());
#else
const typename Simd::Float32x4 v_min = Simd::v_dup(0.0f);
#endif
const typename Simd::Float32x4 v_max = Simd::v_dup(float(GRADIENT_STOPTABLE_SIZE-1));
const typename Simd::Float32x4 v_half = Simd::v_dup(0.5f);

View File

@ -2963,10 +2963,6 @@ void fpe_steepSlopes()
void fpe_radialGradients()
{
#if defined(Q_PROCESSOR_ARM)
QEXPECT_FAIL("", "Test fails for ARM (QTBUG-59961)", Continue);
#endif
FpExceptionChecker checker(FE_UNDERFLOW | FE_OVERFLOW | FE_INVALID | FE_DIVBYZERO);
QImage img(21, 21, QImage::Format_ARGB32_Premultiplied);