Compiler fails to inline simple code.
Original Reporter info from Mantis: Xor-el
-
Reporter name: Ugochukwu Mmaduekwe
Original Reporter info from Mantis: Xor-el
- Reporter name: Ugochukwu Mmaduekwe
Description:
Compiler fails to inline simple code even in O4 optimization
Below is a comparison of Delphi 10.2.3 x86_64 output and that of FPC 3.3.1 -r43642 [2019/12/05] for x86_64 on Windows
Delphi 10.2.3
// Main() Procedure Start
InliningDemo.dpr.14: begin
0000000000426F70 55 push rbp
0000000000426F71 4883EC30 sub rsp,$30
0000000000426F75 488BEC mov rbp,rsp
InliningDemo.dpr.15: ZeroMemory(LBuffer, System.SizeOf(LBuffer));
==================================================== ZeroMemory Function Inline Start
0000000000426F78 488D4D2B lea rcx,[rbp+$2b]
0000000000426F7C C7C205000000 mov edx,$00000005
0000000000426F82 4D33C0 xor r8,r8
0000000000426F85 E846F4FDFF call @FillChar
==================================================== ZeroMemory Function Inline End
InliningDemo.dpr.16: end;
0000000000426F8A 488D6530 lea rsp,[rbp+$30]
0000000000426F8E 5D pop rbp
0000000000426F8F C3 ret
// Main() Procedure End
=================================================================================
FPC Trunk
// Main() Procedure Start
# [14] begin
leaq -40(%rsp),%rsp
# [15] ZeroMemory(LBuffer, System.SizeOf(LBuffer));
leaq 32(%rsp),%rax
movl $5,%edx
movq %rax,%rcx
call P$INLININGDEMO_$$_ZEROMEMORY$formal$LONGINT ==> Call instead of inline
# [16] end;
nop
leaq 40(%rsp),%rsp
ret
// Main() Procedure End
Steps to reproduce:
Compile InliningDemo.lpr with -al flag and examine the output assembler.
Mantis conversion info:
- Mantis ID: 36542
- Build: r43642 [2019/12/05] for x86_64
- Version: 3.3.1
- Monitored by: » Xor-el (Ugochukwu Mmaduekwe)