All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] lib/int_sqrt.c: Optimize square root function
@ 2015-02-02 17:12 Anshul Garg
  2015-02-02 19:00 ` Linus Torvalds
  2015-02-02 19:10 ` Joe Perches
  0 siblings, 2 replies; 27+ messages in thread
From: Anshul Garg @ 2015-02-02 17:12 UTC (permalink / raw)
  To: linux-kernel; +Cc: aksgarg1989, anshul.g, torvalds

From: Anshul Garg <aksgarg1989@gmail.com>

Unnecessary instructions are executing even though m is
greater than x so added logic to make m less than equal to
x before performing these operations.

Signed-off-by: Anshul Garg <aksgarg1989@gmail.com>
---
 lib/int_sqrt.c |    3 +++
 1 file changed, 3 insertions(+)

diff --git a/lib/int_sqrt.c b/lib/int_sqrt.c
index 1ef4cc3..64ae722 100644
--- a/lib/int_sqrt.c
+++ b/lib/int_sqrt.c
@@ -22,6 +22,9 @@ unsigned long int_sqrt(unsigned long x)
 		return x;
 
 	m = 1UL << (BITS_PER_LONG - 2);
+
+	while (m > x)
+		m >>= 2;
 	while (m != 0) {
 		b = y + m;
 		y >>= 1;
-- 
1.7.9.5


---
This email has been checked for viruses by Avast antivirus software.
http://www.avast.com


^ permalink raw reply related	[flat|nested] 27+ messages in thread
* [PATCH] lib/int_sqrt.c: Optimize square root function
@ 2015-01-29 13:35 Anshul Garg
  0 siblings, 0 replies; 27+ messages in thread
From: Anshul Garg @ 2015-01-29 13:35 UTC (permalink / raw)
  To: linux-kernel; +Cc: aksgarg1989, anshul.g

From: Anshul Garg <aksgarg1989@gmail.com>

Unnecessary instructions are executing even though m is
greater than x so added logic to make m less than equal to
x before performing these operations.

Signed-off-by: Anshul Garg <aksgarg1989@gmail.com>
---
 lib/int_sqrt.c |    3 +++
 1 file changed, 3 insertions(+)

diff --git a/lib/int_sqrt.c b/lib/int_sqrt.c
index 1ef4cc3..64ae722 100644
--- a/lib/int_sqrt.c
+++ b/lib/int_sqrt.c
@@ -22,6 +22,9 @@ unsigned long int_sqrt(unsigned long x)
 		return x;
 
 	m = 1UL << (BITS_PER_LONG - 2);
+
+	while (m > x)
+		m >>= 2;
 	while (m != 0) {
 		b = y + m;
 		y >>= 1;
-- 
1.7.9.5


---
This email has been checked for viruses by Avast antivirus software.
http://www.avast.com


^ permalink raw reply related	[flat|nested] 27+ messages in thread

end of thread, other threads:[~2017-07-21 13:33 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-02 17:12 [PATCH] lib/int_sqrt.c: Optimize square root function Anshul Garg
2015-02-02 19:00 ` Linus Torvalds
2015-02-02 19:13   ` Linus Torvalds
2015-02-03  4:41     ` Davidlohr Bueso
2015-02-03  4:57       ` Davidlohr Bueso
2015-02-03 15:54       ` Anshul Garg
2017-07-20 11:24     ` Peter Zijlstra
2017-07-20 11:52       ` Joe Perches
2017-07-20 14:13         ` Peter Zijlstra
2017-07-20 15:27       ` Peter Zijlstra
2017-07-20 18:31       ` Linus Torvalds
2017-07-20 22:34         ` Peter Zijlstra
2017-07-20 23:24           ` Linus Torvalds
2017-07-21 11:40             ` Peter Zijlstra
2017-07-21 12:15               ` Joe Perches
2017-07-21 13:26                 ` Peter Zijlstra
2017-07-21 13:33                   ` Peter Zijlstra
2015-02-03  4:47   ` Davidlohr Bueso
2015-02-03 15:42     ` Anshul Garg
2015-02-05 18:20       ` Linus Torvalds
2015-02-05 18:33         ` Linus Torvalds
2015-02-05 18:43           ` Anshul Garg
2015-02-05 19:37             ` Linus Torvalds
2015-02-08 15:39               ` Anshul Garg
2015-02-02 19:10 ` Joe Perches
2015-02-02 19:39   ` Linus Torvalds
  -- strict thread matches above, loose matches on Subject: below --
2015-01-29 13:35 Anshul Garg

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.