From: john stultz Newsflash: GCC not as smart as once hoped. This patch removes some mults since GCC can't figure out how. Pointed out by Roman Zippel. Signed-off-by: John Stultz Cc: Roman Zippel Signed-off-by: Andrew Morton --- include/linux/clocksource.h | 21 ++++++++++----------- 1 files changed, 10 insertions(+), 11 deletions(-) diff -puN include/linux/clocksource.h~time-use-clocksource-abstraction-for-ntp-adjustments-optimize-out-some-mults-since-gcc-cant-avoid-them include/linux/clocksource.h --- devel/include/linux/clocksource.h~time-use-clocksource-abstraction-for-ntp-adjustments-optimize-out-some-mults-since-gcc-cant-avoid-them 2006-05-10 21:32:57.000000000 -0700 +++ devel-akpm/include/linux/clocksource.h 2006-05-10 21:33:03.000000000 -0700 @@ -236,7 +236,6 @@ static inline int error_aproximation(u64 * * Where mult_delta is the adjustment value made to mult * - * XXX - Hopefully gcc is smart enough to avoid the multiplies. */ static inline s64 make_ntp_adj(struct clocksource *clock, cycles_t cycles_delta, s64* error) @@ -244,27 +243,27 @@ static inline s64 make_ntp_adj(struct cl s64 ret = 0; if (*error > ((s64)clock->interval_cycles+1)/2) { /* calculate adjustment value */ - int adjustment = 1 << error_aproximation(*error, + int adjustment = error_aproximation(*error, clock->interval_cycles); /* adjust clock */ - clock->mult += adjustment; - clock->interval_snsecs += clock->interval_cycles * adjustment; + clock->mult += 1 << adjustment; + clock->interval_snsecs += clock->interval_cycles << adjustment; /* adjust the base and error for the adjustment */ - ret = -(cycles_delta * adjustment); - *error -= clock->interval_cycles * adjustment; + ret = -(cycles_delta << adjustment); + *error -= clock->interval_cycles << adjustment; /* XXX adj error for cycle_delta offset? */ } else if ((-(*error)) > ((s64)clock->interval_cycles+1)/2) { /* calculate adjustment value */ - int adjustment = 1 << error_aproximation(-(*error), + int adjustment = error_aproximation(-(*error), clock->interval_cycles); /* adjust clock */ - clock->mult -= adjustment; - clock->interval_snsecs -= clock->interval_cycles * adjustment; + clock->mult -= 1 << adjustment; + clock->interval_snsecs -= clock->interval_cycles << adjustment; /* adjust the base and error for the adjustment */ - ret = cycles_delta * adjustment; - *error += clock->interval_cycles * adjustment; + ret = cycles_delta << adjustment; + *error += clock->interval_cycles << adjustment; /* XXX adj error for cycle_delta offset? */ } return ret; _