[英]Odd memcpy_s behaviour in VS2015
recently I was profiling one application, and I have noticed that memcpy_s assembly implementation behaves strangely. 最近我在分析一个应用程序,我注意到memcpy_s程序集实现的行为很奇怪。 I'm talking about implementation residing in Microsoft Visual Studio 14.0\\VC\\crt\\src\\i386\\memcpy.asm I'm reaching the CopyUpLargeMov: then I expect it to choose the SSE2 path, or use any other available optimized implementation.
我正在谈论驻留在Microsoft Visual Studio 14.0 \\ VC \\ crt \\ src \\ i386 \\ memcpy.asm中的实现我到达CopyUpLargeMov:然后我希望它选择SSE2路径,或者使用任何其他可用的优化实现。 the code as following:
代码如下:
CopyUpLargeMov:
bt __favor, __FAVOR_ENFSTRG ; check if Enhanced Fast Strings is supported
jnc CopyUpSSE2Check ; if not, check for SSE2 support
rep movsb
mov eax,[esp + 0Ch] ; return original destination pointer
pop esi
pop edi
M_EXIT
Whatever I do with optimization tweaking it never reaches CopyUpSSE2Check
. 无论我如何处理优化调整,它都不会到达
CopyUpSSE2Check
。
Tested with Release|Win32, VS2015 Upd3, Windows10 x64. 使用Release | Win32,VS2015 Upd3,Windows10 x64进行测试。
The actual C++ code 实际的C ++代码
std::vector<uint8_t> src(1024*1024*20,0);
std::vector<uint8_t> dst(1024*1024*20,0);
for (auto i = 0ul; i < 1000; ++i)
{
memcpy_s(dst.data(), dst.size(), src.data(), src.size());
}
Any ideas? 有任何想法吗?
EDIT001: EDIT001:
It seems that x64 does not exhibits the strange behavior, it falls into Enhanced Fast Strings optimization part of the code. 似乎x64没有表现出奇怪的行为,它属于增强快速字符串优化部分的代码。 Maybe the above a x86 limitation?
也许上面的x86限制?
As @EOF pointed out in his comment, the rep movsb
is the optimization. 正如@EOF在他的评论中指出的那样,
rep movsb
就是优化。 It moves the data from string to string, so called "enhanced fast strings" optimization. 它将数据从字符串移动到字符串,因此称为“增强快速字符串”优化。 So I just overlooked it, the
memcpy
is working as it expected to work. 所以我只是忽略了它,
memcpy
正在按预期工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.