From 5127c269fcbd7a5b3f7f0ec9b027ffea21657082 Mon Sep 17 00:00:00 2001 From: ZhuangYumin Date: Thu, 24 Oct 2024 07:02:50 +0000 Subject: [PATCH] enable DCE remove phi --- src/opt/dce.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/opt/dce.cpp b/src/opt/dce.cpp index 8ff3987..afa2134 100644 --- a/src/opt/dce.cpp +++ b/src/opt/dce.cpp @@ -53,6 +53,15 @@ void ConductDCEForFunction(std::shared_ptr func) { block->actions.push_back(act); } } + std::vector phi_to_remove; + for (auto [key, phi_act] : block->phi_map) { + if (phi_act->marked_as_useless) { + phi_to_remove.push_back(key); + } + } + for (auto key : phi_to_remove) { + block->phi_map.erase(key); + } } } std::shared_ptr DCE(std::shared_ptr src) {