Intel® oneAPI DPC++/C++ Compiler
Talk to fellow users of Intel® oneAPI DPC++/C++ Compiler and companion tools like Intel® oneAPI DPC++ Library, Intel® DPC++ Compatibility Tool, and Intel® Distribution for GDB*

Compiler Bugs (use different registers)

hyungseok
Beginner
351 Views

I discovered that ICC 2021.10.0 sometimes overlooks memory size directives.

I found that ICC incorrectly checks memory size for 11 opcodes when compiling x64 or x86 binaries.

 

The buggy code contains 11 opcodes.

void bug(int num) {
__asm__(".intel_syntax noprefix\n"
"cldemote ZMMWORD PTR [1]\n"
"clflush ZMMWORD PTR [1]\n"
"clflushopt ZMMWORD PTR [1]\n"
"clwb ZMMWORD PTR [1]\n"
"invlpg ZMMWORD PTR [1]\n"
"prefetch ZMMWORD PTR [1]\n"
"prefetchw ZMMWORD PTR [1]\n"
"prefetcht0 ZMMWORD PTR [1]\n"
"prefetcht1 ZMMWORD PTR [1]\n"
"prefetcht2 ZMMWORD PTR [1]\n"
"prefetchwt1 ZMMWORD PTR [1]\n"
);
}

 

Compiled Code

bug:
push rbp
mov rbp,rsp
sub rsp,0x10
mov DWORD PTR [rbp-0x10],edi
cldemote BYTE PTR ds:0x1
clflush BYTE PTR ds:0x1
clflushopt BYTE PTR ds:0x1
clwb BYTE PTR ds:0x1
invlpg BYTE PTR ds:0x1
prefetch BYTE PTR ds:0x1
prefetchw BYTE PTR ds:0x1
prefetcht0 BYTE PTR ds:0x1
prefetcht1 BYTE PTR ds:0x1
prefetcht2 BYTE PTR ds:0x1
prefetchwt1 BYTE PTR ds:0x1
leave
ret

 

You can replay the bug through the godbolt.

https://godbolt.org/z/7Ka8na468

0 Kudos
1 Reply
Alex_Y_Intel
Moderator
282 Views

ICC has been deprecated and removed from our oneAPI Base Toolkit since later versions in 2023. Please migrate to using ICX compiler instead. 

0 Kudos
Reply