mirror of
https://github.com/openmv/openmv.git
synced 2025-11-04 14:49:50 +08:00
Merge pull request #1663 from openmv/fmath_rounding
imlib: Optimize fmath ceilf and floorf functions.
This commit is contained in:
commit
5094a1800e
@ -62,7 +62,7 @@ int OMV_ATTR_ALWAYS_INLINE fast_floorf(float x)
|
||||
{
|
||||
int i;
|
||||
asm volatile (
|
||||
"vcvt.S32.f32 %[r], %[x]\n"
|
||||
"vcvtm.S32.f32 %[r], %[x]\n"
|
||||
: [r] "=t" (i)
|
||||
: [x] "t" (x));
|
||||
return i;
|
||||
@ -71,9 +71,8 @@ int OMV_ATTR_ALWAYS_INLINE fast_floorf(float x)
|
||||
int OMV_ATTR_ALWAYS_INLINE fast_ceilf(float x)
|
||||
{
|
||||
int i;
|
||||
x += 0.9999f;
|
||||
asm volatile (
|
||||
"vcvt.S32.f32 %[r], %[x]\n"
|
||||
"vcvtp.S32.f32 %[r], %[x]\n"
|
||||
: [r] "=t" (i)
|
||||
: [x] "t" (x));
|
||||
return i;
|
||||
@ -83,7 +82,7 @@ int OMV_ATTR_ALWAYS_INLINE fast_roundf(float x)
|
||||
{
|
||||
int i;
|
||||
asm volatile (
|
||||
"vcvtr.s32.f32 %[r], %[x]\n"
|
||||
"vcvtr.S32.F32 %[r], %[x]\n"
|
||||
: [r] "=t" (i)
|
||||
: [x] "t" (x));
|
||||
return i;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user