mirror of
https://github.com/byteworksinc/ORCA-C.git
synced 2024-12-21 16:29:31 +00:00
Fix a flawed optimization.
The optimization could turn an unsigned comparison "x <= 0xFFFF" into "x < 0". Here is an example affected by this: int main(void) { unsigned i = 1; return (i <= 0xffff); }
This commit is contained in:
parent
76e4b1f038
commit
7b0dda5a5e
5
DAG.pas
5
DAG.pas
@ -1850,8 +1850,9 @@ case op^.opcode of {check for optimizations of this node}
|
||||
end; {if}
|
||||
end; {case}
|
||||
end {if}
|
||||
else if (op^.opcode = pc_leq) and (op^.optype in [cgWord,cgUWord]) then
|
||||
if op^.right^.q < maxint then begin
|
||||
else if (op^.opcode = pc_leq) then
|
||||
if ((op^.optype = cgWord) and (op^.right^.q <> maxint))
|
||||
or ((op^.optype = cgUWord) and (op^.right^.q <> -1)) then begin
|
||||
op^.right^.q := op^.right^.q + 1;
|
||||
op^.opcode := pc_les;
|
||||
end; {if}
|
||||
|
2
cc.notes
2
cc.notes
@ -1865,6 +1865,8 @@ int foo(int[42]);
|
||||
|
||||
201. When certain expressions were used for the condition in an if statement, loop, or conditional expression, the conditional branch might be evaluated incorrectly, leading to incorrect control flow. The affected condition expressions included shifts, loads or stores of bit-fields, and ? : expressions.
|
||||
|
||||
202. Some comparisons against the constant 0xFFFF would give the wrong result when intermediate code peephole optimization was used.
|
||||
|
||||
-- Bugs from C 2.1.0 that have been fixed -----------------------------------
|
||||
|
||||
1. In some situations, fread() reread the first 1K or so of the file.
|
||||
|
Loading…
Reference in New Issue
Block a user