Detect whether we have a native 64-bit type?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Is there any portable way in GCC to detect whether the architecture we’re targeting has a fast native 64-bit type?

The motivation is that there are operations that it’s faster to do as a single 64-bit multiplication if the architecture really supports native 64-bit operations, but if instead 64-bit is emulated, it’s faster to write multiple 32-bit multiplications.

My specific motivation is the Opus audio codec, which has code like:

/* (a32 * (b32 >> 16)) >> 16 */
#if OPUS_FAST_INT64
#define silk_SMULWT(a32, b32)            ((opus_int32)(((a32) * (opus_int64)((b32) >> 16)) >> 16))
#else
#define silk_SMULWT(a32, b32)            (((a32) >> 16) * ((b32) >> 16) + ((((a32) & 0x0000FFFF) * ((b32) >> 16)) >> 16))
#endif

Right now, OPUS_FAST_INT64 is set like:
/* Set this if opus_int64 is a native type of the CPU. */
/* Assume that all LP64 architectures have fast 64-bit types; also x86_64 (which can be ILP32 for x32)
   and Win64 (which is LLP64). */
#if defined(__LP64__) || defined(__x86_64__) || defined(_WIN64)
#define OPUS_FAST_INT64 1
#endif
But this isn’t complete; I know there are any number of 64-bit platforms that have x32-style ABIs.  Rather than enumerate them all, is there some way I can get this information from GCC directly?  (Extra points if it works on Clang as well.)

Thanks!




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux