assembly - Most efficient/idiomatic way to test a 256-bit YMM AVX register for zero -


i have x86_64 routine ends 0 in ymm register if successful, , i'd return non-zero if ymm register.

i have way clearing ymm register, vptest'ing register against one, , conditionally incrementing resturn register (rax in case) if cf not set:

"    xor    %%rax,   %%rax              \n" // clear rax  "    vxorpd %%ymm0,  %%ymm0,    %%ymm0  \n" // clear ymm0 "    vptest %%ymm1,  %%ymm0             \n" // compare ymm1 0  "    jc     endcheck                    \n" // branch on if no residue "    inc    %%rax                       \n" // inc rax otherwise  "endcheck:                              \n" // result in rax 

this seems opaque way it. there better way, or more idiomatic or readable way?

combining comments above, can done in 3 lines of assembly:

"xor         %%rax,      %%rax    \n" // clear rax "vptest      %%ymm1,     %%ymm1   \n" // if ymm1 zero, set zf "setnz       %%al                 \n" // set byte in rax if not 0 

this seems clearer , more had in mind.


Comments

Popular posts from this blog

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

php - render data via PDO::FETCH_FUNC vs loop -

The canvas has been tainted by cross-origin data in chrome only -