From 734eb2ce62624c8500b2d7fd3677280bdeeca94a Mon Sep 17 00:00:00 2001 From: Alex Coyte Date: Mon, 16 Jan 2017 10:14:41 +1100 Subject: [PATCH] we can only trim lookarounds based on information common to all literals --- src/rose/rose_build_lookaround.cpp | 34 +++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/src/rose/rose_build_lookaround.cpp b/src/rose/rose_build_lookaround.cpp index d2c4b541..10bd59de 100644 --- a/src/rose/rose_build_lookaround.cpp +++ b/src/rose/rose_build_lookaround.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015-2016, Intel Corporation + * Copyright (c) 2015-2017, Intel Corporation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -460,17 +460,41 @@ void findFloodReach(const RoseBuildImpl &tbi, const RoseVertex v, } } +static +map findLiteralReach(const rose_literal_id &lit) { + map look; + + u32 i = lit.delay + 1; + for (auto it = lit.s.rbegin(), ite = lit.s.rend(); it != ite; ++it) { + look[0 - i] |= *it; + i++; + } + + return look; +} + static map findLiteralReach(const RoseBuildImpl &build, const RoseVertex v) { + bool first = true; map look; for (u32 lit_id : build.g[v].literals) { const rose_literal_id &lit = build.literals.right.at(lit_id); + auto lit_look = findLiteralReach(lit); - u32 i = lit.delay + 1; - for (auto it = lit.s.rbegin(), ite = lit.s.rend(); it != ite; ++it) { - look[0 - i] |= *it; - i++; + if (first) { + look = move(lit_look); + first = false; + } else { + for (auto it = look.begin(); it != look.end();) { + auto l_it = lit_look.find(it->first); + if (l_it == lit_look.end()) { + it = look.erase(it); + } else { + it->second |= l_it->second; + ++it; + } + } } }