有人可以解释这个 SSE BigNum 比较吗? [英] can someone explain this SSE BigNum comparison?
问题描述
如果你看看这个 answer,作者设法为存储在 2 个 SSE 寄存器中的 2 个整数 bignum 创建了一个紧凑的比较算法.我没有很好地遵循它:)
If you look at this answer, the author manages to create a compact comparison algorithm for 2 integer bignums, stored in 2 SSE registers. I am not following it too well :)
到目前为止我做了什么:
What I did so far:
if l = a 和
e = a == b = {a[i] == b[i] ? ~0 : 0}
然后 a
但这似乎不是作者在做什么.我错过了什么?有什么需要大于比较的?
But this does not seem to be what the author is doing. What am I missing? What need is there for a greater than comparison?
推荐答案
我忽略了答案不是通用的,而是仅限于由 32 位元素组成的 64 位 bignum.如果您有 2 个 64 位向量 a = {a0, a1}
, b = {b0, b1}
,则程序计算:
I've overlooked than the answer was not generic, but limited to 64-bit bignums, composed out of 32-bit elements. If you have 2 64-bit vectors a = {a0, a1}
, b = {b0, b1}
, then the program calculates:
a < b = ((a1 < b1) | (a0 < b0)) & ~(a1 > b1)
在我的问题中,我的目标是使用 SSE/AVX 寄存器实现的任意长的 BigNum.
In my question I was aiming at arbitrarily long BigNums, implemented with SSE/AVX registers.
这篇关于有人可以解释这个 SSE BigNum 比较吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!