Variable locations with SSA varies in a block, comment in assembler needs to be updated
Original Reporter info from Mantis: Vincent
-
Reporter name: Vincent Snijders
Original Reporter info from Mantis: Vincent
- Reporter name: Vincent Snijders
Description:
The generated code with SSA looks very nice. As a consequence, the (pascal) variable doesn't need to be in the same register during its lifetime. Therefore the comment in the assembler source about the variable location is not correct and might be confusing.
Steps to reproduce:
Given the following program:
program sse2test;
{$mode objfpc}{$H+}
{$fputype sse2}
var
Zr, Zi, Tr, Ti, Cr, Ci: double;
begin
Cr := 1.5;
Ci := 1.2;
Zr := 0; Zi := 0; Tr := 0; Ti := 0;
Zi := 2*Zr*Zi + Ci;
Zr := Tr - Ti + Cr;
Ti := Zi * Zi;
Tr := Zr * Zr;
Zi := 2*Zr*Zi + Ci;
Zr := Tr - Ti + Cr;
Ti := Zi * Zi;
Tr := Zr * Zr;
end.
A part of the assmebler code generated with -al looks like:
# Var Zr located in register mreg5md
# Var Zi located in register mreg6md
# Var Tr located in register mreg0md
# Var Ti located in register mreg0md
# Var Cr located in register mreg4md
# Var Ci located in register mreg3md
&LtPos;snip>
# [11] Zr := 0; Zi := 0; Tr := 0; Ti := 0;
movsd _$PROGRAM$_Ld3,%xmm5
movsd _$PROGRAM$_Ld3,%xmm6
movsd _$PROGRAM$_Ld3,%xmm1
movsd _$PROGRAM$_Ld3,%xmm2
Tr is now in %xmm1 and Ti is now in %xmm2
# [12] Zi := 2*Zr*Zi + Ci;
movsd _$PROGRAM$_Ld4,%xmm0
mulsd %xmm5,%xmm0
mulsd %xmm6,%xmm0
addsd %xmm3,%xmm0
Zi is now in %xmm0
# [13] Zr := Tr - Ti + Cr;
subsd %xmm2,%xmm1
addsd %xmm4,%xmm1
Zr is now in %xmm1
After these lines Zi, Zr, Ti and Tr are at different locations as set in the comments at the top.
Additional information:
Maybe the solution is to update variable location just before or just after each line or statement.
Mantis conversion info:
- Mantis ID: 7552
- OS: Windows
- OS Build: XP Home SP2
- Build: 4793
- Platform: i386
- Version: 2.2.0
- Fixed in version: 3.0.0
- Fixed in revision: 18278 (#68dd23b5)