You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
https://doc.rust-lang.org/nightly/reference/inline-assembly.html#register-names
says about k0 "This is a constant zero register which can't be modified."
That's the same phrasing as AArch64 xzr, so I assume the author thought it was architecturally hard-wired, rather than a software choice to keep it zeroed (like often done with AVR r0). (Which I don't think would make much sense; most instructions with an all-zero mask are no-ops so you don't normally want one.)
k0 is special in that it can't be used as a mask, because that register number means no-masking if used in an instruction like vmovaps (%rdi), %xmm0{%k1}{z}. But it can be the destination of instructions like compare-into-mask or vptestmd %ymm0, %ymm0, %k0, and then stored to memory or copied to a GP-integer reg with kmovd %k0, %eax, tested with kortest, combine with other masks with kunpck or kadd or whatever.
Leaving it unused prevents false dependencies when materializing an all-ones mask with kxnord %k0, %k0, %k1 (e.g. before a gather), but otherwise there's no reason to avoid it if your uses for that mask don't include applying masking to other instructions.
Probably not much reason to invent a constraint like Yk but which can pick k0..7, though, but it's possible it could help register allocation of mask regs with surrounding code. (But would be more documentation to wade through, and could end up wasting some people's time if they find the constraint which can pick k0 when they need one which can't.)
The text was updated successfully, but these errors were encountered:
pcordes
changed the title
Inline asm docs incorrectly state the k0 (x86 AVX-512) is hard-wired to zero
Inline asm docs incorrectly state that k0 (x86 AVX-512) is hard-wired to zero
Mar 15, 2022
asm: Add a kreg0 register class on x86 which includes k0
Previously we only exposed a kreg register class which excludes the k0
register since it can't be used in many instructions. However k0 is a
valid register and we need to have a way of marking it as clobbered for
clobber_abi.
Fixesrust-lang#94977
Previously we only exposed a kreg register class which excludes the k0
register since it can't be used in many instructions. However k0 is a
valid register and we need to have a way of marking it as clobbered for
clobber_abi.
Fixesrust-lang#94977
antoyo
pushed a commit
to antoyo/rust
that referenced
this issue
Jun 7, 2022
asm: Add a kreg0 register class on x86 which includes k0
Previously we only exposed a kreg register class which excludes the k0
register since it can't be used in many instructions. However k0 is a
valid register and we need to have a way of marking it as clobbered for
clobber_abi.
Fixesrust-lang#94977
https://doc.rust-lang.org/nightly/reference/inline-assembly.html#register-names
says about
k0
"This is a constant zero register which can't be modified."That's the same phrasing as AArch64
xzr
, so I assume the author thought it was architecturally hard-wired, rather than a software choice to keep it zeroed (like often done with AVRr0
). (Which I don't think would make much sense; most instructions with an all-zero mask are no-ops so you don't normally want one.)k0
is special in that it can't be used as a mask, because that register number means no-masking if used in an instruction likevmovaps (%rdi), %xmm0{%k1}{z}
. But it can be the destination of instructions like compare-into-mask orvptestmd %ymm0, %ymm0, %k0
, and then stored to memory or copied to a GP-integer reg withkmovd %k0, %eax
, tested withkortest
, combine with other masks withkunpck
orkadd
or whatever.Leaving it unused prevents false dependencies when materializing an all-ones mask with
kxnord %k0, %k0, %k1
(e.g. before a gather), but otherwise there's no reason to avoid it if your uses for that mask don't include applying masking to other instructions.You do definitely want there to be a constraint that can only pick k1..7, not k0, like GNU C inline asm's
Yk
(https://stackoverflow.com/questions/55946103/gnu-c-inline-asm-input-constraint-for-avx512-mask-registers-k1-k7), but there's no reason to disallowk0
as an explicit choice. If people don't want to know about details like k0 being special, they can use intrinsics.Probably not much reason to invent a constraint like
Yk
but which can pick k0..7, though, but it's possible it could help register allocation of mask regs with surrounding code. (But would be more documentation to wade through, and could end up wasting some people's time if they find the constraint which can pick k0 when they need one which can't.)The text was updated successfully, but these errors were encountered: