Intel® C++ Compiler Classic Developer Guide and Reference

ID 767249
Date 12/16/2022
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

_may_i_use_cpu_feature

Queries the processor dynamically at the source level (this intrinsic does not perform a vendor check) to determine if processor-specific features are available.

Syntax

extern int _may_i_use_cpu_feature(unsigned __int64);

Arguments

unsigned __int64

An unsigned __int64 bitset representing one or more cpuid features. The arguments for feature query accepted by this intrinsic is:

_FEATURE_GENERIC_IA32

_FEATURE_FPU

_FEATURE_CMOV

_FEATURE_MMX

_FEATURE_FXSAVE

_FEATURE_SSE

_FEATURE_SSE2

_FEATURE_SSE3

_FEATURE_SSSE3

_FEATURE_SSE4_1

_FEATURE_SSE4_2

_FEATURE_POPCNT

_FEATURE_MOVBE

_FEATURE_PCLMULQDQ

_FEATURE_AES

_FEATURE_F16C

_FEATURE_AVX

_FEATURE_RDRND

_FEATURE_FMA

_FEATURE_BMI

_FEATURE_LZCNT

_FEATURE_HLE

_FEATURE_RTM

_FEATURE_AVX2

_FEATURE_ADX

_FEATURE_RDSEED

_FEATURE_AVX512DQ

_FEATURE_AVX512F

_FEATURE_AVX512ER

_FEATURE_AVX512PF

_FEATURE_AVX512CD

_FEATURE_AVX512BW

_FEATURE_AVX512VL

_FEATURE_SHA

_FEATURE_MPX

_FEATURE_AVX512IFMA52

_FEATURE_AVX512VBMI

_FEATURE_AVX512_4FMAPS

_FEATURE_AVX512_4VNNIW

Description

This intrinsic queries the processor on which it is running to check the availability of the given features. This check is dynamically performed at the point in the source where it is called. For example:

if (_may_i_use_cpu_feature(_FEATURE_SSE4_2)) { 
			Use SSE4.2 intrinsics; 
} Else { 
			Use generic code; 
} 

The _may_i_use_feature intrinsic, in this case, dynamically checks if the code is being executed on a processor that supports SSE4.2, and returns true if it is supported, or false. The _may_i_use_feature also accepts multiple features within a single argument, for example:

if (_may_i_use_cpu_feature(_FEATURE_SSE | 
					_FEATURE_SSE2 | 
					_FEATURE_SSE3 | 
					_FEATURE_SSSE3 | 
					_FEATURE_MOVBE) && 
					!_may_i_use_cpu_feature(_FEATURE_SSE4_1)) {
printf("\nYou are running on an Atom processor."\n");
}  

This intrinsic does not perform processor vendor checks that other features do (-m <cpu> type option).

Returns

Result of the feature query, true or false (1 or 0) for whether the set of features is available on the machine on which the intrinsic is executed.

See Also