8086-msdos: Ineffective code generation for longint multiplication
Original Reporter info from Mantis: kagamma
-
Reporter name:
Original Reporter info from Mantis: kagamma
- Reporter name:
Description:
Example code:
{$mode objfpc}
// Hacky fixed point multiplication, expect B >= 0 with no fractional part
function FixedMul(const A, B: LongInt): LongInt;
begin
Result := A * Word(B shr 16);
end;
begin
Writeln(FixedMul(5 shl 16, 3 shl 16));
end.
This is the result after compiling with "-O4 -Wtcom -Cp80286" flags:
; [6] Result := A * Word(B shr 16);
%LINE 6+0
mov ax,word [bp+8]
mov dx,word [bp+10]
; Var A located in register ax:dx
push dx
push ax
mov ax,word [bp+6]
mov dx,0
mov dx,0
push dx
push ax
call fpc_mul_longint
2 ineffective "mov dx,0" were generated, one for (B shr 16), and another was for typecasting from LongInt to Word.
Mantis conversion info:
- Mantis ID: 38658
- Build: 49040
- Version: 3.3.1