SSE4.1自动将字符串比较放在较新的gcc上 [英] SSE4.1 automatically put in string comparison on newer gcc

查看:160
本文介绍了SSE4.1自动将字符串比较放在较新的gcc上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我搜索了gcc 4.8.1文件,但找不到这个答案:



我有一些SSE4.1代码和回退代码,在运行时我检测系统是否支持SSE4.1,如果没有,我使用回退代码。



到目前为止很好,但是最新的gcc版本发生:



- 我的应用程序崩溃,因为每次执行字符串比较时,SSE4.1指令都会遍布代码

由于我用-msse41编译所有文件这听起来很合理,但崩溃了我的代码。我的问题是这样:有什么办法来限制SSE41使用只是那个使用SSE4.1的代码?不幸的是,这些头文件随处可用,所以用msse41编译那些翻译单元是相当困难的。

解决方案

,您可以使用多版本功能,请参阅 http://gcc.gnu.org/gcc -4.8 / changes.html ,查找使用G ++的函数多版本支持。免责声明:我没有使用这个(至今)。


I searched the gcc 4.8.1 documents but couldn't find an answer to this:

I have some SSE4.1 code and fallback code, at runtime I detect whether the system supports SSE4.1 and in case it doesn't, I use the fallback code.

So far so good, but with latest gcc versions this is what happens:

- my application crashes because SSE4.1 instructions are being spread throughout the code every time a string comparison is performed

Since I'm compiling all my files with -msse41 this sounds reasonable but crashes my code. My question is this: is there any way to restrict SSE41 usage to just that code which makes use of SSE4.1? Unfortunately these are header files used everywhere so it would be rather difficult to just compile those translation units with msse41

解决方案

As of GCC 4.8, you can use multi-versioned functions, see http://gcc.gnu.org/gcc-4.8/changes.html, look for "Function Multiversioning Support with G++". Disclaimer: I did not use this (as of yet).

这篇关于SSE4.1自动将字符串比较放在较新的gcc上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆