Too aggressive optimization
Original Reporter info from Mantis: pfgx
-
Reporter name: Alexander
Original Reporter info from Mantis: pfgx
- Reporter name: Alexander
Description:
Optimizer drops branches and break down code flow.
This happens in some situations, looks as template "while &LtPos;expr> do &LtPos;action>;", while optimization is enabled.
Steps to reproduce:
program test:
var v:longword;
begin
if v=2 then while true do ;
end.
fpc -a -al -Os test.pas
correct:
\# [4] if v=2 then while true do ;<br/>
cmpl $2,U_$P$PROGRAM_$$_V
je .Lj3
jmp .Lj4
.Lj3:
jmp .Lj6
.Lj5:
.Lj6:
jmp .Lj5
.Lj4:
# [5] end.
> fpc -a -al -Os -O1 test.pas incorrect: # [4] if v=2 then while true do ; cmpl $2,U_$P$PROGRAM_$$_V je .Lj5 .Lj5: # [5] end.
> fpc -a -al -Os -O3 test.pas more incorrect: # [4] if v=2 then while true do ; cmpl $2,%eax
[5] end.
Mantis conversion info:
- Mantis ID: 36139
- OS: Ubuntu
- OS Build: 18.04.3
- Platform: x86_64
- Version: 3.0.4
- Fixed in version: 3.3.1
- Fixed in revision: 43175 (#67fc9a78)