mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: john stultz <johnstul@us.ibm.com>
To: Andrew Morton <akpm@osdl.org>
Cc: lkml <linux-kernel@vger.kernel.org>,
	Roman Zippel <zippel@linux-m68k.org>
Subject: [PATCH] Time: optimize out some mults, since gcc can't avoid them
Date: Fri, 05 May 2006 18:44:33 -0700	[thread overview]
Message-ID: <1146879873.12414.3.camel@cog.beaverton.ibm.com> (raw)

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 <johnstul@us.ibm.com>

diff --git a/include/linux/clocksource.h b/include/linux/clocksource.h
index 585789f..5f4a7f7 100644
--- a/include/linux/clocksource.h
+++ b/include/linux/clocksource.h
@@ -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;



                 reply	other threads:[~2006-05-06  1:44 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1146879873.12414.3.camel@cog.beaverton.ibm.com \
    --to=johnstul@us.ibm.com \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=zippel@linux-m68k.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®