* fixed adjustments of lower/upper bounds in range test optimization in case

of strictly smaller/greater comparisons (mantis #34385)

git-svn-id: trunk@40344 -
This commit is contained in:
Jonas Maebe 2018-11-17 22:38:31 +00:00
parent 4dfb738130
commit d1361ca6ed
3 changed files with 28 additions and 4 deletions

1
.gitattributes vendored
View File

@ -16415,6 +16415,7 @@ tests/webtbs/tw3433.pp svneol=native#text/plain
tests/webtbs/tw34332.pp svneol=native#text/pascal
tests/webtbs/tw3435.pp svneol=native#text/plain
tests/webtbs/tw34380.pp svneol=native#text/plain
tests/webtbs/tw34385.pp svneol=native#text/plain
tests/webtbs/tw3441.pp svneol=native#text/plain
tests/webtbs/tw3443.pp svneol=native#text/plain
tests/webtbs/tw34438.pp svneol=native#text/pascal

View File

@ -377,11 +377,11 @@ implementation
function taddnode.simplify(forinline : boolean) : tnode;
function is_range_test(nodel, noder: taddnode; var value: tnode; var cl,cr: Tconstexprint): boolean;
function is_range_test(nodel, noder: taddnode; out value: tnode; var cl,cr: Tconstexprint): boolean;
const
is_upper_test: array[ltn..gten] of boolean = (true,true,false,false);
inclusive_adjust: array[boolean,ltn..gten] of integer = ((1,0,-1,0),
(-1,0,1,0));
inclusive_adjust: array[boolean,ltn..gten] of integer = ((-1,0,1,0),
(1,0,-1,0));
var
swapl, swapr: Boolean;
valuer: tnode;
@ -1056,7 +1056,7 @@ implementation
if is_boolean(left.resultdef) and is_boolean(right.resultdef) then
begin
{ transform unsigned comparisons of (v>=x) and (v<=y)
into (v-x)<(y-x)
into (v-x)<=(y-x)
}
if (nodetype=andn) and
(left.nodetype in [ltn,lten,gtn,gten]) and

23
tests/webtbs/tw34385.pp Normal file
View File

@ -0,0 +1,23 @@
program rangeTest;
const
w : dword = 123;
n : dword = 48;
begin
if (w<=1) and (w>=10) then
begin
writeln('error 1-10');
halt(1);
end;
if (w>=1) and (w<=1000) then
writeln('ok')
else
begin
writeln('error 1-1000');
halt(2);
end;
if (n>44)and(n<48) then
begin
writeln('error 48');
halt(3);
end;
end.