- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sample code:
int f(int n)
{
int x[n];
return sizeof x;
}
Invocation:
$ icc t0.c -std=c11 -pedantic -Wall -Wextra -c -O3
<nothing>
Expected generated code:
f: # @f
lea eax, [4*rdi]
ret
(or similar)
Actual generated code:
f:
push rbp #2.1
mov rbp, rsp #2.1
movsxd rdi, edi #2.1
shl rdi, 2 #3.6
mov rax, rdi #3.6
add rax, 15 #3.6
and rax, -16 #3.6
sub rsp, rax #3.6
mov rax, rsp #3.6
mov rdx, rax #4.16
mov rax, rdi #4.16
add rax, 15 #4.16
and rax, -16 #4.16
add rsp, rax #4.16
mov eax, edi #4.2
mov rsp, rbp #4.2
pop rbp #4.2
ret #4.2
Version: icc 2021.5.0 on x86-64 on Linux
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Thank you for posting in Intel communities.
We were able to reproduce your issue at our end with icc. Could you please try with Intel C++ Compiler 2022 (icx) compiler as it is generating the expected assembly code?
Not sure if you are aware of it, but the Intel C++ Classic compiler will enter "Legacy Product Support" mode signaling the end of regular updates. Please see the below article for more details.
Thanks & Regards,
Madhu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@MadhuK_Intel icx is OK:
f(int): #
lea eax, [4*rdi]
ret
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Glad to know that your issue is resolved. If you need any additional information, please post a new question as this thread will no longer be monitored by Intel.
Thanks and regards,
Madhu

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page