Thread overview
popcnt instruction
Jun 24, 2014
Archibald
Jun 24, 2014
Justin Whear
Jun 24, 2014
Rene Zwanenburg
Jun 24, 2014
Archibald
Jun 24, 2014
Justin Whear
Jun 24, 2014
Justin Whear
Jun 24, 2014
Archibald
June 24, 2014
Hello,
I need to use the "popcnt" processor instruction in a performance critical section.
Is there a way to do this in D?
June 24, 2014
On Tue, 24 Jun 2014 16:34:42 +0000, Archibald wrote:

> Hello,
> I need to use the "popcnt" processor instruction in a performance
> critical section.
> Is there a way to do this in D?

D's inline assembler is described here: http://dlang.org/iasm.html
June 24, 2014
On Tuesday, 24 June 2014 at 17:05:24 UTC, Justin Whear wrote:
> On Tue, 24 Jun 2014 16:34:42 +0000, Archibald wrote:
>
>> Hello,
>> I need to use the "popcnt" processor instruction in a performance
>> critical section.
>> Is there a way to do this in D?
>
> D's inline assembler is described here: http://dlang.org/iasm.html

There's also an intrinsic in core.bitop:
http://dlang.org/library/core/bitop/popcnt.html
June 24, 2014
On Tuesday, 24 June 2014 at 17:27:09 UTC, Rene Zwanenburg wrote:
> On Tuesday, 24 June 2014 at 17:05:24 UTC, Justin Whear wrote:
>> On Tue, 24 Jun 2014 16:34:42 +0000, Archibald wrote:
>>
>>> Hello,
>>> I need to use the "popcnt" processor instruction in a performance
>>> critical section.
>>> Is there a way to do this in D?
>>
>> D's inline assembler is described here: http://dlang.org/iasm.html
>
> There's also an intrinsic in core.bitop:
> http://dlang.org/library/core/bitop/popcnt.html


Thanks for the answers.
Unfortunately it seems like popcnt isn't supported by D's inline
assembler.
What if I import it as an external C function, will I get optimal
performance?
June 24, 2014
On Tue, 24 Jun 2014 19:44:52 +0000, Archibald wrote:

> Thanks for the answers.
> Unfortunately it seems like popcnt isn't supported by D's inline
> assembler.
> What if I import it as an external C function, will I get optimal
> performance?

DMD 2.065 seems to support it.  What compiler are you using and what errors are you getting?
June 24, 2014
Also, see: http://forum.dlang.org/thread/alirjgygnwpifkijxtjo@forum.dlang.org
June 24, 2014
On Tuesday, 24 June 2014 at 19:56:29 UTC, Justin Whear wrote:
> Also, see:
> http://forum.dlang.org/thread/alirjgygnwpifkijxtjo@forum.dlang.org

"its not documented on the inline assembler page."
That's why I thought it wasn't supported, it's not in the list of supported opcodes.
Thanks for the help!