Explicitly optimize x/x in Classic Jerk (#18112)

Can we outsmart the compiler?
2.0.x
XDA-Bam 5 years ago committed by GitHub
parent f776260d7a
commit 5fbea83840
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -2456,16 +2456,16 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
// Pick the smaller of the nominal speeds. Higher speed shall not be achieved at the junction during coasting. // Pick the smaller of the nominal speeds. Higher speed shall not be achieved at the junction during coasting.
CACHED_SQRT(previous_nominal_speed, previous_nominal_speed_sqr); CACHED_SQRT(previous_nominal_speed, previous_nominal_speed_sqr);
vmax_junction = _MIN(nominal_speed, previous_nominal_speed); float smaller_speed_factor = 1.0f;
if (nominal_speed < previous_nominal_speed) {
vmax_junction = nominal_speed;
smaller_speed_factor = vmax_junction / previous_nominal_speed;
}
else
vmax_junction = previous_nominal_speed;
// Now limit the jerk in all axes. // Now limit the jerk in all axes.
const float smaller_speed_factor = vmax_junction / previous_nominal_speed; TERN(HAS_LINEAR_E_JERK, LOOP_XYZ, LOOP_XYZE)(axis) {
#if HAS_LINEAR_E_JERK
LOOP_XYZ(axis)
#else
LOOP_XYZE(axis)
#endif
{
// Limit an axis. We have to differentiate: coasting, reversal of an axis, full stop. // Limit an axis. We have to differentiate: coasting, reversal of an axis, full stop.
float v_exit = previous_speed[axis] * smaller_speed_factor, float v_exit = previous_speed[axis] * smaller_speed_factor,
v_entry = current_speed[axis]; v_entry = current_speed[axis];

Loading…
Cancel
Save