# ymm0 holds the counters
# ymm1 holds the limits
# ymm2 holds 1 in each byte (or 0xff in each byte and use vpsubb)
# ymm3 holds 0 in each byte
vpcmpeqb %ymm0, %ymm3, %ymm4 # which of the counters is zero?
vptest %ymm4, %ymm4 # clear ZF if any counter was zero
vpsubb %ymm2, %ymm0, %ymm0 # decrement counters
vpminub %ymm1, %ymm0, %ymm0 # reset rolled-over counters to limits
jnz .Lrollover # do something if a counter rolled over
1条答案
按热度按时间hts6caw31#
我建议将计数器减1后存储。也就是说,它们从 limit-1 开始,你希望在它们从0翻转到-1时得到通知,而不是从1翻转到0。然后你可以解决这个问题如下:
这段代码是为了说明一般的想法。有关如何使其更快的一些提示,请参阅下面的Peter Cordes的精彩评论。