diff --git a/compiler/aoptobj.pas b/compiler/aoptobj.pas index 08b27d0262..39f9d0f13c 100644 --- a/compiler/aoptobj.pas +++ b/compiler/aoptobj.pas @@ -918,7 +918,10 @@ Unit AoptObj; (taicpu(p1).is_jmp) then if { the next instruction after the label where the jump hp arrives} { is unconditional or of the same type as hp, so continue } - ((taicpu(p1).opcode = aopt_uncondjmp) or + (((taicpu(p1).opcode = aopt_uncondjmp) and + (taicpu(p1).oper[0]^.typ = top_ref) and + (assigned(taicpu(p1).oper[0]^.ref^.symbol)) and + (taicpu(p1).oper[0]^.ref^.symbol is TAsmLabel)) or conditions_equal(taicpu(p1).condition,hp.condition)) or { the next instruction after the label where the jump hp arrives} { is the opposite of hp (so this one is never taken), but after } @@ -929,7 +932,10 @@ Unit AoptObj; SkipLabels(p1,p2) and (p2.typ = ait_instruction) and (taicpu(p2).is_jmp) and - ((taicpu(p2).opcode = aopt_uncondjmp) or + (((taicpu(p2).opcode = aopt_uncondjmp) and + (taicpu(p2).oper[0]^.typ = top_ref) and + (assigned(taicpu(p2).oper[0]^.ref^.symbol)) and + (taicpu(p2).oper[0]^.ref^.symbol is TAsmLabel)) or (conditions_equal(taicpu(p2).condition,hp.condition))) and SkipLabels(p1,p1)) then begin @@ -1000,7 +1006,10 @@ Unit AoptObj; { the following if-block removes all code between a jmp and the next label, because it can never be executed } - if (taicpu(p).opcode = aopt_uncondjmp) then + if (taicpu(p).opcode = aopt_uncondjmp) and + (taicpu(p).oper[0]^.typ = top_ref) and + (assigned(taicpu(p).oper[0]^.ref^.symbol)) and + (taicpu(p).oper[0]^.ref^.symbol is TAsmLabel) then begin while GetNextInstruction(p, hp1) and (hp1.typ <> ait_label) do @@ -1030,6 +1039,9 @@ Unit AoptObj; SkipLabels(hp1,hp1); if (tai(hp1).typ=ait_instruction) and (taicpu(hp1).opcode=aopt_uncondjmp) and + (taicpu(hp1).oper[0]^.typ = top_ref) and + (assigned(taicpu(hp1).oper[0]^.ref^.symbol)) and + (taicpu(hp1).oper[0]^.ref^.symbol is TAsmLabel) and GetNextInstruction(hp1, hp2) and FindLabel(tasmlabel(taicpu(p).oper[0]^.ref^.symbol), hp2) then begin