A note on mask registers (AVX-512)
travisdowns.github.io
travisdowns.github.io
I was actually surprised to see the zeroing idioms not being recognized. I sort of assumed those were cheap to implement. I suppose they may not actually have much value since you would never actually want to use a zero mask register as an actual mask?
I can't see all that many scenarios where you want a zeroed register to begin with. Many of the cases that happens in the GP world (e.g., zeroing out some accumulator or pointer or whatever) just don't come up in mask registers.
I am not sure about the cost to implement it. I don't think it's all that complicated to describe how it would work, but it does occur in the renamer, which is a critical path on modern chips, so probably the less complication there, the better. We already know that not all zeroing idioms are recognized (like sub same, same) on some chips, so that is some indication that it's not super cheap (or else you'd think they'd have just implemented all the idioms the first time around).
I mean, if you are going to zero the register, the real optimization would be to completely skip emitting any instructions for the operation you are going to perform, since it probably isn't going to do anything if the mask is cleared.