* more case fixes

git-svn-id: trunk@40706 -
This commit is contained in:
florian 2018-12-29 21:53:52 +00:00
parent 514c0e06a5
commit bd4b7a6bc4
2 changed files with 18 additions and 13 deletions

View File

@ -723,7 +723,7 @@ implementation
hregister:=scratch_reg; hregister:=scratch_reg;
opsize:=newdef; opsize:=newdef;
end; end;
if labelcnt>1 then if (labelcnt>1) or not(cs_opt_level1 in current_settings.optimizerswitches) then
begin begin
last:=0; last:=0;
first:=true; first:=true;
@ -739,7 +739,7 @@ implementation
begin begin
scratch_reg:=hlcg.getintregister(current_asmdata.CurrAsmList,opsize); scratch_reg:=hlcg.getintregister(current_asmdata.CurrAsmList,opsize);
gensub(tcgint(hp^._low.svalue)); gensub(tcgint(hp^._low.svalue));
hlcg.a_cmp_const_reg_label(current_asmdata.CurrAsmList, opsize, OC_BE, tcgint(hp^._high.svalue-hp^._low.svalue), hregister, blocklabel(hp^.blockid)) hlcg.a_cmp_const_reg_label(current_asmdata.CurrAsmList, opsize, jmp_le, tcgint(hp^._high.svalue-hp^._low.svalue), hregister, blocklabel(hp^.blockid))
end; end;
end; end;
hlcg.a_jmp_always(current_asmdata.CurrAsmList,elselabel); hlcg.a_jmp_always(current_asmdata.CurrAsmList,elselabel);
@ -1224,6 +1224,9 @@ implementation
else else
{$endif not cpu64bitalu} {$endif not cpu64bitalu}
begin begin
labelcnt := 0;
TrueCount := 0;
if cs_opt_level1 in current_settings.optimizerswitches then if cs_opt_level1 in current_settings.optimizerswitches then
begin begin
{ procedures are empirically passed on } { procedures are empirically passed on }
@ -1233,8 +1236,6 @@ implementation
{ moreover can the size only be appro- } { moreover can the size only be appro- }
{ ximated as it is not known if rel8, } { ximated as it is not known if rel8, }
{ rel16 or rel32 jumps are used } { rel16 or rel32 jumps are used }
labelcnt := 0;
TrueCount := 0;
CountBoth(labels); CountBoth(labels);

View File

@ -223,6 +223,8 @@ implementation
opcgsize: tcgsize; opcgsize: tcgsize;
procedure genitem(t : pcaselabel); procedure genitem(t : pcaselabel);
var
range, gap: aint;
begin begin
if assigned(t^.less) then if assigned(t^.less) then
genitem(t^.less); genitem(t^.less);
@ -245,6 +247,7 @@ implementation
end end
else else
begin begin
range := aint(t^._high.svalue - t^._low.svalue);
{ it begins with the smallest label, if the value } { it begins with the smallest label, if the value }
{ is even smaller then jump immediately to the } { is even smaller then jump immediately to the }
{ ELSE-label } { ELSE-label }
@ -256,6 +259,7 @@ implementation
end end
else else
begin begin
gap := aint(t^._low.svalue - last.svalue);
{ if there is no unused label between the last and the } { if there is no unused label between the last and the }
{ present label then the lower limit can be checked } { present label then the lower limit can be checked }
{ immediately. else check the range in between: } { immediately. else check the range in between: }
@ -263,23 +267,23 @@ implementation
{ we need to use A_SUB, if cond_lt uses the carry flags { we need to use A_SUB, if cond_lt uses the carry flags
because A_DEC does not set the correct flags, therefor because A_DEC does not set the correct flags, therefor
using a_op_const_reg(OP_SUB) is not possible } using a_op_const_reg(OP_SUB) is not possible }
if (cond_lt in [F_C,F_NC,F_A,F_AE,F_B,F_BE]) and (aint(t^._low.svalue-last.svalue)=1) then if (gap = 1) and (cond_lt in [F_C,F_NC,F_A,F_AE,F_B,F_BE]) then
emit_const_reg(A_SUB,TCGSize2OpSize[opcgsize],aint(t^._low.svalue-last.svalue),hregister) emit_const_reg(A_SUB, TCGSize2OpSize[opcgsize], gap, hregister)
else else
cg.a_op_const_reg(current_asmdata.CurrAsmList, OP_SUB, opcgsize, aint(t^._low.svalue-last.svalue), hregister); cg.a_op_const_reg(current_asmdata.CurrAsmList, OP_SUB, opcgsize, gap, hregister);
{ no jump necessary here if the new range starts at { no jump necessary here if the new range starts at
at the value following the previous one } at the value following the previous one }
if ((t^._low-last) <> 1) or if (gap <> 1) or
(not lastrange) then (not lastrange) then
cg.a_jmp_flags(current_asmdata.CurrAsmList,cond_lt,elselabel); cg.a_jmp_flags(current_asmdata.CurrAsmList,cond_lt,elselabel);
end; end;
{ we need to use A_SUB, if cond_le uses the carry flags { we need to use A_SUB, if cond_le uses the carry flags
because A_DEC does not set the correct flags, therefor because A_DEC does not set the correct flags, therefor
using a_op_const_reg(OP_SUB) is not possible } using a_op_const_reg(OP_SUB) is not possible }
if (cond_le in [F_C,F_NC,F_A,F_AE,F_B,F_BE]) and (aint(t^._high.svalue-t^._low.svalue)=1) then if (cond_le in [F_C,F_NC,F_A,F_AE,F_B,F_BE]) and (range = 1) then
emit_const_reg(A_SUB,TCGSize2OpSize[opcgsize],aint(t^._high.svalue-t^._low.svalue),hregister) emit_const_reg(A_SUB,TCGSize2OpSize[opcgsize], range, hregister)
else else
cg.a_op_const_reg(current_asmdata.CurrAsmList, OP_SUB, opcgsize, aint(t^._high.svalue-t^._low.svalue), hregister); cg.a_op_const_reg(current_asmdata.CurrAsmList, OP_SUB, opcgsize, range, hregister);
cg.a_jmp_flags(current_asmdata.CurrAsmList,cond_le,blocklabel(t^.blockid)); cg.a_jmp_flags(current_asmdata.CurrAsmList,cond_le,blocklabel(t^.blockid));
last:=t^._high; last:=t^._high;
@ -311,7 +315,7 @@ implementation
genlinearcmplist(hp) genlinearcmplist(hp)
else else
begin begin
if labelcnt>1 then if (labelcnt>1) or not(cs_opt_level1 in current_settings.optimizerswitches) then
begin begin
last:=0; last:=0;
lastrange:=false; lastrange:=false;
@ -326,7 +330,7 @@ implementation
else else
begin begin
cg.a_op_const_reg(current_asmdata.CurrAsmList, OP_SUB, opcgsize, tcgint(hp^._low.svalue), hregister); cg.a_op_const_reg(current_asmdata.CurrAsmList, OP_SUB, opcgsize, tcgint(hp^._low.svalue), hregister);
cg.a_cmp_const_reg_label(current_asmdata.CurrAsmList, opcgsize, OC_BE, tcgint(hp^._high.svalue - hp^._low.svalue), hregister,blocklabel(hp^.blockid)); cg.a_cmp_const_reg_label(current_asmdata.CurrAsmList, opcgsize, jmp_le, tcgint(hp^._high.svalue - hp^._low.svalue), hregister,blocklabel(hp^.blockid));
end; end;
end; end;
cg.a_jmp_always(current_asmdata.CurrAsmList,elselabel); cg.a_jmp_always(current_asmdata.CurrAsmList,elselabel);