From 31cdb29de46d08af3b721ce62377b6faa614cc32 Mon Sep 17 00:00:00 2001 From: Florian Hahn Date: Mon, 24 Aug 2020 12:12:15 +0100 Subject: [PATCH] [DSE,MemorySSA] Return early when hitting a MemoryPhi. A MemoryPhi can never be eliminated. If we hit one, return the Phi, so the caller can continue traversing the incoming accesses. This saves some unnecessary read clobber checks and improves compile-time http://llvm-compile-time-tracker.com/compare.php?from=1ffc58b6d098ce8fa71f3a80fe75b990f633f921&to=d0fa8d1982380b57d7b6067528104bc373dbe07a&stat=instructions --- llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp index ae4cc56..9825dfd 100644 --- a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp +++ b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp @@ -1847,8 +1847,10 @@ struct DSEState { return None; WalkerStepLimit -= StepCost; + // Return for MemoryPhis. They cannot be eliminated directly and the + // caller is responsible for traversing them. if (isa(Current)) - break; + return Current; // Below, check if CurrentDef is a valid candidate to be eliminated by // KillingDef. If it is not, check the next candidate. -- 2.7.4