1
0
Fork 0
mirror of https://github.com/iNavFlight/inav.git synced 2025-07-19 06:15:14 +03:00

Replace ABS(float) with fabsf(float)

Disregarding loads and stores, fabfs() compiles to a single vabs.f32
instruction, which completes in 1 cycle. ABS(float), however, compiles
to vcmpe.f32, a branch and vneg.f32, which needs 2 cycles + branching.
The compiler is not able to perform this transformation because
(f < 0 ? -f : f) doesn't always yield the absolute value for
floats (e.g. ABS(-0) will yield -0).
This commit is contained in:
Alberto García Hierro 2019-01-19 17:10:14 +00:00
parent b0d285d66d
commit 0f4e74cd04
10 changed files with 14 additions and 14 deletions

View file

@ -410,7 +410,7 @@ int16_t applyFixedWingMinSpeedController(timeUs_t currentTimeUs)
float velThrottleBoost = (NAV_FW_MIN_VEL_SPEED_BOOST - posControl.actualState.velXY) * NAV_FW_THROTTLE_SPEED_BOOST_GAIN * US2S(deltaMicrosPositionUpdate);
// If we are in the deadband of 50cm/s - don't update speed boost
if (ABS(posControl.actualState.velXY - NAV_FW_MIN_VEL_SPEED_BOOST) > 50) {
if (fabsf(posControl.actualState.velXY - NAV_FW_MIN_VEL_SPEED_BOOST) > 50) {
throttleSpeedAdjustment += velThrottleBoost;
}