can someone explain this SSE BigNum comparison?

自古美人都是妖i 提交于 2020-01-17 10:10:07

问题


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 < b = {a[i] < b[i] ? ~0 : 0} and

e = a == b = {a[i] == b[i] ? ~0 : 0}

then a < b == l[3] v e[3]l[2] v e[3]e[2]l[1] v e[3]e[2]e[1]l[0]

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?


回答1:


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)

In my question I was aiming at arbitrarily long BigNums, implemented with SSE/AVX registers.



来源:https://stackoverflow.com/questions/27929402/can-someone-explain-this-sse-bignum-comparison

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!