[PATCH] D121987: [EarlyCSE] Don't eagerly optimize MemoryUses

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 18 02:08:32 PDT 2022


nikic created this revision.
nikic added reviewers: asbirlea, fhahn, reames.
Herald added a subscriber: hiraditya.
Herald added a project: All.
nikic requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

EarlyCSE currently optimizes all MemoryUses upfront. However, EarlyCSE only actually queries the clobbering memory access for a subset of uses, namely those where a CSE candidate has already been identified.

Delaying use optimization to the clobber query improves compile-time in practice: http://llvm-compile-time-tracker.com/compare.php?from=59191057243e34d85b644716ef2811bfea8efd1e&to=1dd3499045716e71bad61ccd70700e734a74d350&stat=instructions

This change is not NFC because EarlyCSE has a limit on the number of clobber queries (EarlyCSEMssaOptCap), in which case it falls back to the defining access. The defining access for uses will now no longer coincide with the optimized access. If there are performance regressions from this change, we should be able to address them by raising this limit.


https://reviews.llvm.org/D121987

Files:
  llvm/lib/Transforms/Scalar/EarlyCSE.cpp


Index: llvm/lib/Transforms/Scalar/EarlyCSE.cpp
===================================================================
--- llvm/lib/Transforms/Scalar/EarlyCSE.cpp
+++ llvm/lib/Transforms/Scalar/EarlyCSE.cpp
@@ -598,10 +598,7 @@
            const TargetTransformInfo &TTI, DominatorTree &DT,
            AssumptionCache &AC, MemorySSA *MSSA)
       : TLI(TLI), TTI(TTI), DT(DT), AC(AC), SQ(DL, &TLI, &DT, &AC), MSSA(MSSA),
-        MSSAUpdater(std::make_unique<MemorySSAUpdater>(MSSA)) {
-    if (MSSA)
-      MSSA->ensureOptimizedUses();
-  }
+        MSSAUpdater(std::make_unique<MemorySSAUpdater>(MSSA)) {}
 
   bool run();
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D121987.416430.patch
Type: text/x-patch
Size: 624 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220318/6d4c0dcf/attachment.bin>


More information about the llvm-commits mailing list