Support asm x86 popcnt (#2314)

* Support asm x86 popcnt
This commit is contained in:
hamkoroke
2025-07-21 09:40:17 +09:00
committed by GitHub
parent 908d705669
commit 382a65abcd
2 changed files with 29 additions and 0 deletions

25
test/unit/asm/popcnt.c3 Normal file
View File

@@ -0,0 +1,25 @@
module test::inline_asm::popcnt @if (env::X86_64);
fn void popcntw() @test
{
short src = 0xF0;
short count = 0;
asm { popcntw count, src; }
assert(count == 4, "inline asm: popcntw failed");
}
fn void popcntl() @test
{
int src = 0xF0F0;
int count = 0;
asm { popcntl count, src; }
assert(count == 8, "inline asm: popcntl failed");
}
fn void popcntq() @test
{
long src = 0xF0F0_F0F0;
long count = 0;
asm { popcntq count, src; }
assert(count == 16, "inline asm: popcntq failed");
}