gpt4 book ai didi

linux - 使用 SSE 指令的 Memcpy

转载 作者:塔克拉玛干 更新时间:2023-11-03 02:08:28 24 4
gpt4 key购买 nike

我正在尝试使用 SSE 指令使用 memcpy 函数。我在互联网上找到了这个文件 ( ftp://ftp.acer.at/gpl/AS9100/GPL_AS9100/xine-lib/src/xine-utils/memcpy.c )。这是我遇到问题的代码部分:

__asm__ __volatile__ (
"prefetchnta 320(%0)\n"
"prefetchnta 352(%0)\n"
"movups (%0), %%xmm0\n"
"movups 16(%0), %%xmm1\n"
"movups 32(%0), %%xmm2\n"
"movups 48(%0), %%xmm3\n"
"movntps %%xmm0, (%1)\n"
"movntps %%xmm1, 16(%1)\n"
"movntps %%xmm2, 32(%1)\n"
"movntps %%xmm3, 48(%1)\n"
:: "r" (from), "r" (to) : "memory");
((const unsigned char *)from)+=64;
((unsigned char *)to)+=64;

from 和 to 是 void * pointers and 在最后两行,我遇到了这个错误:

error: lvalue required as left operand of assignment

如果可以,请帮助我。

谢谢

最佳答案

(*(const unsigned char **)&from)

是您正在寻找的左值。

但这样写可能对优化器更友好

from = ((const unsigned char *)from) + 64;

这避免了需要内存溢出的寻址运算符。

另一种方法是在进入函数时将参数转换为具有正确类型的局部变量,并且永远不要再接触函数参数。

关于linux - 使用 SSE 指令的 Memcpy,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33226068/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com