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;
|
int i;
|
||||||
asm volatile (
|
asm volatile (
|
||||||
"vcvt.S32.f32 %[r], %[x]\n"
|
"vcvtm.S32.f32 %[r], %[x]\n"
|
||||||
: [r] "=t" (i)
|
: [r] "=t" (i)
|
||||||
: [x] "t" (x));
|
: [x] "t" (x));
|
||||||
return i;
|
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 OMV_ATTR_ALWAYS_INLINE fast_ceilf(float x)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
x += 0.9999f;
|
|
||||||
asm volatile (
|
asm volatile (
|
||||||
"vcvt.S32.f32 %[r], %[x]\n"
|
"vcvtp.S32.f32 %[r], %[x]\n"
|
||||||
: [r] "=t" (i)
|
: [r] "=t" (i)
|
||||||
: [x] "t" (x));
|
: [x] "t" (x));
|
||||||
return i;
|
return i;
|
||||||
@ -83,7 +82,7 @@ int OMV_ATTR_ALWAYS_INLINE fast_roundf(float x)
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
asm volatile (
|
asm volatile (
|
||||||
"vcvtr.s32.f32 %[r], %[x]\n"
|
"vcvtr.S32.F32 %[r], %[x]\n"
|
||||||
: [r] "=t" (i)
|
: [r] "=t" (i)
|
||||||
: [x] "t" (x));
|
: [x] "t" (x));
|
||||||
return i;
|
return i;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user