This is an archive of the discontinued LLVM Phabricator instance.

[DSE,MemorySSA] Check if DomAccess is valid for elimination first.
ClosedPublic

Authored by fhahn on Aug 24 2020, 2:20 PM.

Details

Summary

This changes getDomMemoryDef to check if a DomAccess is a valid
candidate for elimination before checking for reads. Before the change,
we were spending a lot of compile-time in checking for read accesses for
DomAccess that might not even be removable.

This patch flips the logic, so we skip DomAccesses if they cannot be
removed before checking all their uses. This is much more efficient in
practice.

It also adds a more aggressive limit for checking partially overlapping
stores. The main problem with overlapping stores is that we do not know
if they will lead to elimination until seeing all of them. This patch
limits adds a new limit for overlapping store candidates, which keeps
the number of modified overlapping stores roughly the same.

This is another substantial compile-time improvement (while also
increasing the number of stores eliminated). Geomean -O3 -0.67%,
ReleaseThinLTO -0.97%.

http://llvm-compile-time-tracker.com/compare.php?from=0a929b6978a068af8ddb02d0d4714a2843dd8ba9&to=2e630629b43f64b60b282e90f0d96082fde2dacc&stat=instructions

Diff Detail

Event Timeline

fhahn created this revision.Aug 24 2020, 2:20 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 24 2020, 2:20 PM
fhahn requested review of this revision.Aug 24 2020, 2:20 PM
xbolva00 added inline comments.
llvm/test/Transforms/DeadStoreElimination/MSSA/simple.ll
479–480

Remove todo?

fhahn added inline comments.Aug 24 2020, 2:40 PM
llvm/test/Transforms/DeadStoreElimination/MSSA/simple.ll
479–480

Thanks, that looks indeed fixed now :)

645

This change looks wrong, I'll fix that tomorrow.

asbirlea added inline comments.Aug 24 2020, 3:51 PM
llvm/test/Transforms/DeadStoreElimination/MSSA/combined-partial-overwrites.ll
213

Remove "aggressive"

216

Does it make sense to have a RUN line with the cl::opt increasing the limit for a few of the meaningful tests to show the difference? (with check-prefixes)

fhahn updated this revision to Diff 287690.Aug 25 2020, 9:18 AM

Rebase, add check lines to overlap tests with increase partial store limit, add options for thresholds, thanks!

fhahn marked 2 inline comments as done.Aug 25 2020, 9:24 AM
fhahn added inline comments.
llvm/test/Transforms/DeadStoreElimination/MSSA/simple.ll
479–480

Actually, the change was a problem and I think the TODO is invalid. I updated the comment to say we cannot remove store i32 1... because it may be read by the caller if unknown_func unwinds.

fhahn updated this revision to Diff 287935.Aug 26 2020, 5:10 AM

Rebase after dropping getClobberingMemoryAccess from D86486

asbirlea accepted this revision.Aug 27 2020, 3:58 PM

A few nits, but lgtm.

llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
1828–1829

nit: flip naming. Argument to StartAccess and local var that gets modified in loop to Current. Seems easier to follow IMO and it's only 2 lines to update.

1856

s/DomI/CurrentI to match above naming?

llvm/test/Transforms/DeadStoreElimination/MSSA/combined-partial-overwrites.ll
3

use --check-prefixes=CHECK,LARGER-LIMIT to avoid duplication of the check lines that are the same and highlight the optimizations missed by the default limit.

213

Update comment?

This revision is now accepted and ready to land.Aug 27 2020, 3:58 PM
fhahn marked 2 inline comments as done.Aug 28 2020, 3:19 AM

Thanks!

llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
1828–1829

That makes more sense, thanks!

1856

Yes that should be updated as well. Adjusted before committing. Some for DomLoc.

llvm/test/Transforms/DeadStoreElimination/MSSA/combined-partial-overwrites.ll
3

I updated the tests to use --check-prefixes=CHECK,DEFAULT-LIMIT --check-prefixes=CHECK,LARGER-LIMIT respectively. Now CHECK prefixes are shared for all functions that do not change.

213

That must have slipped through, sorry about that. I also removed it from the copied comment in multiblock-overlap.ll

This revision was automatically updated to reflect the committed changes.
fhahn marked 2 inline comments as done.