Skip to content

Commit 91c760c

Browse files
dguzhaevigcbot
authored andcommitted
Corrected negative values handling for fast asinh
Use abs value for calculation
1 parent 0bed77b commit 91c760c

File tree

1 file changed

+9
-4
lines changed
  • IGC/BiFModule/Implementation/Math

1 file changed

+9
-4
lines changed

IGC/BiFModule/Implementation/Math/asinh.cl

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,25 @@ INLINE float __intel_asinh_f32( float x, bool doFast )
2121

2222
if(BIF_FLAG_CTRL_GET(FastRelaxedMath) && (!BIF_FLAG_CTRL_GET(APIRS)) && doFast)
2323
{
24+
float abs_x = SPIRV_OCL_BUILTIN(fabs, _f32, )(x);
2425
// Implemented as log(x + sqrt(x*x + 1)).
2526
// Conformance test checks for this "overflow" case, but
2627
// I don't think we should have to handle it.
27-
if( x > 1500.0f )
28+
if( abs_x > 1500.0f )
2829
{
29-
result = SPIRV_OCL_BUILTIN(log, _f32, )(x) + M_LN2_F;
30+
result = SPIRV_OCL_BUILTIN(log, _f32, )(abs_x) + M_LN2_F;
31+
}
32+
else if (abs_x < 0x1.0p-12) {
33+
result = abs_x;
3034
}
3135
else
3236
{
33-
result = x * x + 1.0f;
37+
result = abs_x * abs_x + 1.0f;
3438
result = SPIRV_OCL_BUILTIN(sqrt, _f32, )( result );
35-
result = x + result;
39+
result = abs_x + result;
3640
result = SPIRV_OCL_BUILTIN(log, _f32, )( result );
3741
}
42+
result = SPIRV_OCL_BUILTIN(copysign, _f32_f32, )(result, x);
3843
}
3944
else
4045
{

0 commit comments

Comments
 (0)