r/C_Programming • u/Salat_Leaf • Jun 21 '26
Question How does my CPU run unsupported instructions?
I've got Intel i7-13620H. My supported instruction set list in CPU-Z:
MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, EM64T, AES, AVX, AVX2, AVX-VNNI, FMA3, SHA
However, when I conditionally compile my program with __VAES__, the macro gets automatically defined at compile time, I even tested it specifically with __attribute__((target("aes,vaes,avx512f"))), it runs without some purple unsupported instruction error that would otherwise appear (at least it does show up on Windows). I checked the assembly, the compiler does not optimize the intrinsics. VAES is only available on AVX512-supported hardware. However, when I run 512-bit version of vaesenc itself, it fails to produce the output when I try to print it in terminal, while 256-bit version successfully computes the result.
How is this possible?
60
u/riotinareasouthwest Jun 21 '26
Well, if it natively runs it, then it's supported from engineering stand regardless of what other says. But sometimes, silicon producers include features in the implementation not theoretically included because it's cheaper doing so that setting up a new production line to avoid having the implementation there. The feature is not tested though so it may work or won't; it may run flawlessly or fail at 70 degrees...
23
u/FUZxxl Jun 21 '26
The VAES extension is not a subset of AVX-512 and there can be CPUs that have it but don't have AVX-512, in which case only the variant operating on YMM registers is available. Without the VAES extension, only the variant operating on XMM registers (mnemonic
aesencorvaesenc) is available.12
u/mikeblas Jun 21 '26
You should show your code and compiler options, and tool chain info. Make a minimal reproducible case.
11
u/zhivago Jun 21 '26
Is it substituting software implementations?
3
u/CapitalStandard4275 Jun 21 '26
I'm a bit confused.
You say when you run the 512-bit version, it doesn't produce output, your CPU doesn't have AVX512 support. Checks out.
When you run the 256-bit version, it works. Your chip supports AVX2 so you'd expect it to.
I'm not understanding how/where your CPU is running unsupported instructions? It reads to me like it doesn't work properly with the unsupported instruction set ("[...] It fails to produce output")
2
u/duane11583 Jun 21 '26
i do not know intel i do know the arm version. arms example was for floating point.
what happens on arm is the illegal instruction interrupt or exception is taken
that handler would normally crash the system but it can examine the instruction and then emulate the instruction (in this example a floating point operation) then resume normal operation at the next opcode
4
u/pigeon768 Jun 21 '26
https://en.wikipedia.org/wiki/AVX-512#VAES
VEX encoding means they're actually AVX2 instructions, not AVX-512 instructions.
1
u/flyingron Jun 21 '26
WTF does this have to do with C?
1
u/Elbrus-matt Jun 21 '26
they all had avx512 support but only the p cores so it was disabled because of the e core unless you have one of those engineering sample you get from china,11th gen was the only consumer one with avx512 fully enabled,it should support avx10 instead which is for 256-bit.
1
u/BirthdayLife6378 Jun 21 '26
Maybe the CPU only supports the 512bits instructions in the P-Cores. Can you write a multithread test program to stress both the P and E cores? I remember that the p cores had the silicons, but not enabled. And the e cores don't have the silicons at all.