Skip to content

Commit

Permalink
DSP: Optimize sqrt using sqrt intrinsic function
Browse files Browse the repository at this point in the history
Signed-off-by: Huaqi Fang <578567190@qq.com>
  • Loading branch information
fanghuaqi committed Jul 31, 2020
1 parent 9ba880a commit c819040
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion NMSIS/DSP/Include/riscv_math.h
Original file line number Diff line number Diff line change
Expand Up @@ -5981,10 +5981,14 @@ __STATIC_FORCEINLINE riscv_status riscv_sqrt_f32(
float32_t in,
float32_t * pOut)
{

if (in >= 0.0f)
{

#if defined ( __riscv_flen )
__ASM volatile("fsqrt.s %0, %1" : "=f"(*pOut) : "f"(in));
#else
*pOut = sqrtf(in);
#endif /*__riscv_flen*/

return (RISCV_MATH_SUCCESS);
}
Expand Down

0 comments on commit c819040

Please sign in to comment.