public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] arch: ia64: kernel: palinfo.c:  Optimization of the Code
@ 2014-06-01 21:43 Rickard Strandqvist
  2014-06-02  7:24 ` Clemens Ladisch
  0 siblings, 1 reply; 3+ messages in thread
From: Rickard Strandqvist @ 2014-06-01 21:43 UTC (permalink / raw)
  To: Tony Luck, Fenghua Yu
  Cc: Rickard Strandqvist, Paul Gortmaker, Rafael J. Wysocki,
	Srivatsa S. Bhat, linux-ia64, linux-kernel

>From what I know, AND is faster then modulo.
Not sure if this is worth changing though.

Signed-off-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
---
 arch/ia64/kernel/palinfo.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/ia64/kernel/palinfo.c b/arch/ia64/kernel/palinfo.c
index c39c3cd..7915b02 100644
--- a/arch/ia64/kernel/palinfo.c
+++ b/arch/ia64/kernel/palinfo.c
@@ -156,7 +156,8 @@ static void bitregister_process(struct seq_file *m, u64 *reg_info, int max)
 
 	for(; i < max; i++ ) {
 
-		if (i != 0 && (i%64) == 0) value = *++reg_info;
+		if (i != 0 && (i&63) == 0)
+			value = *++reg_info;
 
 		if ((value & 0x1) == 0 && skip == 0) {
 			if (begin  <= i - 2)
-- 
1.7.10.4


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

* Re: [PATCH] arch: ia64: kernel: palinfo.c:  Optimization of the Code
  2014-06-01 21:43 [PATCH] arch: ia64: kernel: palinfo.c: Optimization of the Code Rickard Strandqvist
@ 2014-06-02  7:24 ` Clemens Ladisch
  2014-06-02 17:59   ` Rickard Strandqvist
  0 siblings, 1 reply; 3+ messages in thread
From: Clemens Ladisch @ 2014-06-02  7:24 UTC (permalink / raw)
  To: Rickard Strandqvist, Tony Luck, Fenghua Yu
  Cc: Paul Gortmaker, Rafael J. Wysocki, Srivatsa S. Bhat, linux-ia64,
	linux-kernel

Rickard Strandqvist wrote:
> From what I know, AND is faster then modulo.

Which is why the compiler does this optimization automatically,
if it can prove that it is correct.

> -		if (i != 0 && (i%64) == 0)
> +		if (i != 0 && (i&63) == 0)

Did you prove that i cannot be negative?


Regards,
Clemens

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

* Re: [PATCH] arch: ia64: kernel: palinfo.c: Optimization of the Code
  2014-06-02  7:24 ` Clemens Ladisch
@ 2014-06-02 17:59   ` Rickard Strandqvist
  0 siblings, 0 replies; 3+ messages in thread
From: Rickard Strandqvist @ 2014-06-02 17:59 UTC (permalink / raw)
  To: Clemens Ladisch
  Cc: Tony Luck, Fenghua Yu, Paul Gortmaker, Rafael J. Wysocki,
	Srivatsa S. Bhat, linux-ia64, linux-kernel@vger.kernel.org

Hi

Thought I would be able to do that. But after testing, I could not
measure any difference.

Thought it would make a noticeable difference, but guess gcc resolve
this in the best way.


Best regards
Rickard Strandqvist


2014-06-02 9:24 GMT+02:00 Clemens Ladisch <clemens@ladisch.de>:
> Rickard Strandqvist wrote:
>> From what I know, AND is faster then modulo.
>
> Which is why the compiler does this optimization automatically,
> if it can prove that it is correct.
>
>> -             if (i != 0 && (i%64) == 0)
>> +             if (i != 0 && (i&63) == 0)
>
> Did you prove that i cannot be negative?
>
>
> Regards,
> Clemens

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

end of thread, other threads:[~2014-06-02 17:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-01 21:43 [PATCH] arch: ia64: kernel: palinfo.c: Optimization of the Code Rickard Strandqvist
2014-06-02  7:24 ` Clemens Ladisch
2014-06-02 17:59   ` Rickard Strandqvist

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox