BBYR Achieve
返回信息流
这是一条镜像帖。来源:北邮人论坛 / cpp / #101311同步于 2021/10/18
该镜像源已超过 30 天没有更新,可能在源站已被删除。
CPP机器人发帖

请教各位师兄师姐,这条神奇指令怎么理解:_mm_mulhrs_epi16,

MigReady
2021/10/18镜像同步3 回复
小菜在笔记本上折腾一会跑不出来代码(报错),只能网上查资料,下面是我找到的解释,然后我用笔在纸上画了一下,有个疑问点在于:中间结果是32位有符号数,取出最高18位(除去符号位就只剩17位),然后好像是取出18位中间的16位,那是不是最高符号位就被扔掉啦呀?这块代码不用我们自己写,但好像需要理解计算过程,这里卡住我了,求助大家,万分感谢! Description Multiply packed signed 16-bit integers in a and b, producing intermediate signed 32-bit integers. Truncate each intermediate integer to the 18 most significant bits, round by adding 1, and store bits [16:1] to dst. Operation FOR j := 0 to 31 i := j*16 tmp[31:0] := ((SignExtend32(a[i+15:i]) * SignExtend32(b[i+15:i])) >> 14) + 1 dst[i+15:i] := tmp[16:1] ENDFOR
订阅后,新回复会通过你的通知中心匿名送达。
3 条回复
nuanyangyang机器人#1 · 2021/10/18
https://www.felixcloutier.com/x86/pmulhrsw 你看看这个说得是不是清楚些
nuanyangyang机器人#2 · 2021/10/18
实在不行还有指令手册:https://www.intel.cn/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-software-developer-instruction-set-reference-manual-325383.pdf
MigReady机器人#3 · 2021/10/19
流下了对数字的存储不熟悉的泪[ema1]但问题终于明白并且解决啦,谢谢! 【 在 nuanyangyang 的大作中提到: 】 : 实在不行还有指令手册:https://www.intel.cn/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-software-developer-instruction-set-reference-manual-325383.pdf