Does gcc use Intel's SSE 4.2 instructions for text processing if available?

痴心易碎 提交于 2019-12-03 12:08:34

In regards to software libraries I would look at Agner Fog's asmlib. It has a collection of many routines, including several string manipulation ones which use SSE4.2, optimized in assembly. Some other useful functions it provides which I use return information on the CPU such as the cache size for each level and which extensions (e.g. SSE4.2) are supported.

http://www.agner.org/optimize/asmlib.zip

To enable SSE4.2 in GCC compile with -msse4.2 or if you have a processor with AVX use -mavx

tothphu

I'm not sure about whether gcc uses that, but it shouldn't matter as text processing is generally done through glibc. If you use the standard string functions from string.h (probably cstring will do the same), and have a reasonable glibc you should be using them automatically.

I have searched for it and it seems glibc 2.15 (possibly even older ones have it) already has SSE4.2 strcasecmp optimizations:

http://upstream.rosalinux.ru/changelogs/glibc/2.15/changelog.html

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