mirror of
https://github.com/byteworksinc/ORCA-C.git
synced 2025-01-10 12:30:03 +00:00
Fix mis-evaluation of certain equality comparisons with intermediate code optimization.
This affected comparisons of the form "logical operation or comparison == constant other than 0 or 1". These should always evaluate to 0 (false), but could mis-evaluate to true due to the bad optimization. The following program gives an example showing the problem: #pragma optimize 1 int main(void) { int i = 0, j = 42; return (i || j) == 123; }
This commit is contained in:
parent
7266b1d613
commit
db98f7842d
4
DAG.pas
4
DAG.pas
@ -1329,7 +1329,7 @@ case op^.opcode of {check for optimizations of this node}
|
||||
end; {case}
|
||||
end {if}
|
||||
else if op^.right^.optype in [cgByte, cgUByte, cgWord, cgUWord] then begin
|
||||
if op^.right^.q <> 0 then
|
||||
if op^.right^.q = 1 then
|
||||
if op^.left^.opcode in
|
||||
[pc_and,pc_ior,pc_neq,pc_equ,pc_geq,pc_leq,pc_les,pc_grt]
|
||||
then begin
|
||||
@ -1338,7 +1338,7 @@ case op^.opcode of {check for optimizations of this node}
|
||||
end; {if}
|
||||
end {else if}
|
||||
else if op^.right^.optype in [cgLong, cgULong] then begin
|
||||
if op^.right^.lval <> 0 then
|
||||
if op^.right^.lval = 1 then
|
||||
if op^.left^.opcode in
|
||||
[pc_and,pc_ior,pc_neq,pc_equ,pc_geq,pc_leq,pc_les,pc_grt]
|
||||
then begin
|
||||
|
Loading…
x
Reference in New Issue
Block a user