From dbeafbd3712e710248fdea00f4fd7db3994f9e85 Mon Sep 17 00:00:00 2001 From: Bernhard Urban Date: Sun, 2 Sep 2012 19:33:34 +0200 Subject: [PATCH] basicblock: small optimization of algo --- Mate/BasicBlocks.hs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Mate/BasicBlocks.hs b/Mate/BasicBlocks.hs index c94e6d1..dfe1b36 100644 --- a/Mate/BasicBlocks.hs +++ b/Mate/BasicBlocks.hs @@ -125,10 +125,12 @@ markBackwardTargets (x:[]) = [x] markBackwardTargets insns@(x@((x_off,x_bbend),x_ins):y@((y_off,_),_):xs) = x_new:markBackwardTargets (y:xs) where - x_new = if isTarget then checkX y_off else x - checkX w16 = case x_bbend of + x_new = case x_bbend of Just _ -> x -- already marked, don't change + Nothing -> if isTarget then checkX y_off else x + checkX w16 = case x_bbend of Nothing -> ((x_off, Just $ FallThrough w16), x_ins) -- mark previous insn + _ -> error "basicblock: something is wrong" -- look through all remaining insns in the stream if there is a jmp to `y' isTarget = case find cmpOffset insns of Just _ -> True; Nothing -> False -- 2.25.1