From: Borislav Petkov <bp@alien8.de>
To: Jiri Kosina <jikos@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>,
Linus Torvalds <torvalds@linux-foundation.org>,
Ville Syrj??l?? <ville.syrjala@linux.intel.com>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
the arch/x86 maintainers <x86@kernel.org>,
Borislav Petkov <bp@suse.de>, "H . Peter Anvin" <hpa@zytor.com>,
Andy Lutomirski <luto@amacapital.net>,
Brian Gerst <brgerst@gmail.com>,
Denys Vlasenko <dvlasenk@redhat.com>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@kernel.org>
Subject: Re: [PATCH] x86/hweight: Don't clobber %rdi
Date: Mon, 8 Aug 2016 21:17:01 +0200 [thread overview]
Message-ID: <20160808191701.GH511@nazgul.tnic> (raw)
In-Reply-To: <alpine.LRH.2.00.1608082050110.19185@gjva.wvxbf.pm>
On Mon, Aug 08, 2016 at 08:53:16PM +0200, Jiri Kosina wrote:
> Ville's patch is the proper thing to do; I still think the comments
> probably should be removed as they might provide more confusion than help,
> but that's a separate discussion.
Right, so while trying to debug this with a pen and paper, I found that
adding a subsript to the w variable makes it more understandable. I.e.,
something like this:
w_1 -= (w >> 1) & 0x55555555;
w_2 = (w_1 & 0x33333333) + ((w_1 >> 2) & 0x33333333);
and then you'd have
movl %eax, %edx # w
shrl %edx # w >>= 1
andl $0x55555555, %edx # (w >> 1) & 0x55555555
subl %edx, %eax # w_1 = w - ...
movl %eax, %edx # w_1
shrl $2, %eax # w_1 >>= 2
andl $0x33333333, %edx # (w_1 >> 2) & 0x33333333
andl $0x33333333, %eax # w_1 &= 0x33333333
addl %edx, %eax # w_2 = ... + ...
...
Anyway, something like that. I find that more readable TBH.
Thanks and thanks for confirming Ville's patch fixes it on your box.
--
Regards/Gruss,
Boris.
ECO tip #101: Trim your mails when you reply.
--
next prev parent reply other threads:[~2016-08-08 19:38 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-08 17:35 ville.syrjala
2016-08-08 17:58 ` Linus Torvalds
2016-08-08 18:32 ` Peter Zijlstra
2016-08-08 18:53 ` Jiri Kosina
2016-08-08 19:17 ` Borislav Petkov [this message]
2016-08-08 18:04 ` Borislav Petkov
2016-08-08 18:21 ` Linus Torvalds
2016-08-08 18:37 ` Borislav Petkov
2016-08-08 18:45 ` Linus Torvalds
2016-08-08 18:55 ` Borislav Petkov
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=20160808191701.GH511@nazgul.tnic \
--to=bp@alien8.de \
--cc=bp@suse.de \
--cc=brgerst@gmail.com \
--cc=dvlasenk@redhat.com \
--cc=hpa@zytor.com \
--cc=jikos@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@amacapital.net \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
--cc=ville.syrjala@linux.intel.com \
--cc=x86@kernel.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®