[DSE,MemorySSA] Return early when hitting a MemoryPhi.
authorFlorian Hahn <flo@fhahn.com>
Mon, 24 Aug 2020 11:12:15 +0000 (12:12 +0100)
committerFlorian Hahn <flo@fhahn.com>
Sat, 29 Aug 2020 17:28:26 +0000 (18:28 +0100)
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

index ae4cc56..9825dfd 100644 (file)
@@ -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<MemoryPhi>(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.