Skip to content

Commit

Permalink
add tests of lzcnt and tzcnt
Browse files Browse the repository at this point in the history
  • Loading branch information
herumi committed Nov 20, 2023
1 parent 2cc22ea commit c51c4a6
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions test/apx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -930,3 +930,38 @@ CYBOZU_TEST_AUTO(imul_zu)
CYBOZU_TEST_EQUAL(c.getSize(), n);
CYBOZU_TEST_EQUAL_ARRAY(c.getCode(), tbl, n);
}

CYBOZU_TEST_AUTO(lzcnt)
{
struct Code : Xbyak::CodeGenerator {
Code()
{
lzcnt(r16w, r17w);
lzcnt(r16d, r17d);
lzcnt(r16, r17);
lzcnt(r16|T_nf, r17);
lzcnt(rax|T_nf, rcx);
lzcnt(rax, ptr [r18]);

tzcnt(r16w, r17w);
tzcnt(r16d, r17d);
tzcnt(r16, r17);
tzcnt(r16|T_nf, r17);
tzcnt(rax|T_nf, rcx);
tzcnt(rax, ptr [r18]);
}
} c;
const uint8_t tbl[] = {
// lzcnt
0x62, 0xec, 0x7d, 0x08, 0xf5, 0xc1, 0x62, 0xec, 0x7c, 0x08, 0xf5, 0xc1, 0x62, 0xec, 0xfc, 0x08,
0xf5, 0xc1, 0x62, 0xec, 0xfc, 0x0c, 0xf5, 0xc1, 0x62, 0xf4, 0xfc, 0x0c, 0xf5, 0xc1, 0x62, 0xfc,
0xfc, 0x08, 0xf5, 0x02,
// tzcnt
0x62, 0xec, 0x7d, 0x08, 0xf4, 0xc1, 0x62, 0xec, 0x7c, 0x08, 0xf4, 0xc1, 0x62, 0xec, 0xfc, 0x08,
0xf4, 0xc1, 0x62, 0xec, 0xfc, 0x0c, 0xf4, 0xc1, 0x62, 0xf4, 0xfc, 0x0c, 0xf4, 0xc1, 0x62, 0xfc,
0xfc, 0x08, 0xf4, 0x02,
};
const size_t n = sizeof(tbl);
CYBOZU_TEST_EQUAL(c.getSize(), n);
CYBOZU_TEST_EQUAL_ARRAY(c.getCode(), tbl, n);
}

0 comments on commit c51c4a6

Please sign in to comment.