Are there any macros that we can use for instruction set detection?
I know that we have the runtime ones:
if (Avx.IsSupported)
{
//...
}
but do we have defined symboles for that e.g.
#if AVX
//...
#endif
And if there are none, can we create ones or do we have a workaround for that?
NOTE
- while playing with decompiler I found a weird "recursion ". But I think the ILSpy missed here.
.method public hidebysig specialname static
bool get_IsSupported () cil managed
{
// Method begins at RVA 0x142fa4
// Code size 6 (0x6)
.maxstack 8
// return IsSupported;
IL_0000: call bool System.Runtime.Intrinsics.X86.Avx::get_IsSupported()
IL_0005: ret
} // end of method Avx::get_IsSupported
- Also when I looked into a simple
asmcode I noticed the following:
public int F()
{
if (Avx.IsSupported)
return 0;
if (Avx2.IsSupported)
return 1;
return 2;
}
asm
Program.F()
L0000: xor eax, eax
L0002: ret
As you can see it somehow figured out that Avx is supported and didn't include the branches. Is this a normal and well defined behaviour?