Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
所以假设你加载了一个带有 4 个单精度浮点 {1.5、1.5、1.5、1.5} 的 xmm1 向量和带有相同点的 xmm2,所以 xmm1 == xmm2。现在你想比较它们,所以你在汇编中编写:
movaps %xmm1, %xmm2 cmpeqps %xmm0, %xmm2
由于cmpeqps没有设置 eflags,怎么能说:
jne somewhere
真的需要使用ucomiss比较向量的最右边部分,然后向右移动并重复 3 次以上吗?
谢谢
您可以使用cmpeqps,您只需提取四个标志。例如(未测试)
cmpeqps
cmpeqps xmm2, xmm1 movmskps eax, xmm2 cmp eax, 15 je somewhere
向量化算法的算法应设计为避免条件分支。相反,每个通道都执行相同的指令。通常通过评估所有可能的结果并使用掩码选择正确的结果来执行条件。