c++solarissunstudio

ube error: _mm_aeskeygenassist_si128 intrinsic requires at least -xarch=aes


I'm working under Sun Studio 12.3 on SunOS 5.11 (Solaris 11.3). Its providing a compile error that I don't quite understand:

$ /opt/solarisstudio12.3/bin/CC -xarch=sse2 -xarch=aes -xarch=sse4_2 -c test.cxx 
"test.cxx", line 11: ube: error: _mm_aeskeygenassist_si128 intrinsic requires at least -xarch=aes.
CC: ube failed for test.cxx

Adding -m64 produces the same error.

There's not much to the test program. It simply exercises a SSE2 intrinsic, and an AES intrinsic:

$ cat test.cxx
#include <stdint.h>
#include <wmmintrin.h>
#include <emmintrin.h>
int main(int argc, char* argv[])
{
  // SSE2
  int64_t x[2];
  __m128i y = _mm_loadu_si128((__m128i*)x);

  // AES
  __m128i z = _mm_aeskeygenassist_si128(y,0);

  return 0;
}

I've been trying to work through the manual and learn how to specify multiple cpu architecture features, like SSE2, SSSE3, AES and SSE4. But I can't seem to determine how to specify multiple ones. Here's one of the more complete pages I have found: Oracle Man Page CC.1, but I'm obviously missing something with respect to -xarch.

What am I doing wrong, and how do I fix it?


Solution

  • This command line

    $ /opt/solarisstudio12.3/bin/CC -xarch=sse2 -xarch=aes -xarch=sse4_2 -c test.cxx 
    

    will use the last of -xarch=sse2 -xarch=aes -xarch=sse4_2 and cause the compiler to emit sse4_2-compatible binaries.

    This is documented in Chapter 3 of the C++ User's Guide:

    3.2 General Guidelines

    Some general guidelines for the C++ compiler options are:

    • The-llib option links with library liblib.a (or liblib.so). It is always safer to put-llib after the source and object files to ensure the order in which libraries are searched.

    • In general, processing of the compiler options is from left to right (with the exception that-U options are processed after all-D options), allowing selective overriding of macro options (options that include other options). This rule does not apply to linker options.

    • The -features, -I -l, -L, -library, -pti, -R, -staticlib, -U, -verbose, and -xprefetch options accumulate, they do not override.

    • The -D option accumulates. However, multiple -D options for the same name override each other.

    Source files, object files, and libraries are compiled and linked in the order in which they appear on the command line.

    This is done so you can do things like override the expansion of arguments like -fast, which expands to about 10 separate arguments.

    You should use the -xarch=aes flag - either last or as the only -xarch=... option.