Page MenuHomePhabricator

[DSE] Use optimized access if available for redundant store elimination.
ClosedPublic

Authored by fhahn on Oct 22 2021, 6:38 AM.

Details

Summary

Using the optimized access enables additional optimizations in cases
where the defining access is a non-aliasing store.

Alternatively we could also walk upwards and skip non-aliasing defs
here, but my experiments so far showed that this will noticeably
increase compile-time for little extra gain compared to just using the
optimized access.

Improvements of dse.NumRedundantStores on MultiSource/CINT2006/CPF2006
on X86 with -O3:

test-suite...-typeset/consumer-typeset.test     1.00                  76.00              7500.0%
test-suite.../Benchmarks/Bullet/bullet.test     3.00                  12.00              300.0%
test-suite...006/453.povray/453.povray.test     3.00                   6.00              100.0%
test-suite...telecomm-gsm/telecomm-gsm.test     1.00                   2.00              100.0%
test-suite...ediabench/gsm/toast/toast.test     1.00                   2.00              100.0%
test-suite...marks/7zip/7zip-benchmark.test     1.00                   2.00              100.0%
test-suite...ications/JM/lencod/lencod.test     7.00                  10.00              42.9%
test-suite...6/464.h264ref/464.h264ref.test     6.00                   8.00              33.3%
test-suite...ications/JM/ldecod/ldecod.test     6.00                   7.00              16.7%
test-suite...006/447.dealII/447.dealII.test    33.00                  33.00               0.0%
test-suite...6/471.omnetpp/471.omnetpp.test    NaN                     1.00               nan%
test-suite...006/450.soplex/450.soplex.test    NaN                     2.00               nan%
test-suite.../CINT2006/403.gcc/403.gcc.test    NaN                     7.00               nan%
test-suite...lications/ClamAV/clamscan.test    NaN                     1.00               nan%
test-suite...CI_Purple/SMG2000/smg2000.test    NaN                     3.00               nan%

Follow-up to D111727.

Diff Detail

Event Timeline

fhahn created this revision.Oct 22 2021, 6:38 AM
fhahn requested review of this revision.Oct 22 2021, 6:38 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 22 2021, 6:38 AM
fhahn updated this revision to Diff 383604.Oct 30 2021, 10:25 AM

Rebase on top of 0a2b052eb0a59e0df3c8227c1f39d9b1017b38a6.

xbolva00 added inline comments.
llvm/test/Transforms/DeadStoreElimination/stores-of-existing-values.ll
545

Not related to this patch, but this should be strcpy, no?

asbirlea added inline comments.Nov 11 2021, 10:48 AM
llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
1932

Can you please add a comment to document this choice?

This is unusual ... the typical way to do this is: upperDef = getClobberingMemoryAccess which internally returns the optimized access if already optimized, or does the walk if not.
You're looking for bypassing that, due to increase in compile time from the walk. You want the optimized if available, but to not do the walk otherwise and default to the defining access.

Would adding a new API (e.g. getOptimizedIfAvailable) for this sort of info be useful?

fhahn updated this revision to Diff 386650.Nov 11 2021, 1:37 PM

Add comment as suggested and add run lines with flag added in D112313

fhahn marked an inline comment as done.Nov 11 2021, 1:38 PM
fhahn added inline comments.
llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
1932

Thanks, I added a comment to hopefully make things clearer.

Would adding a new API (e.g. getOptimizedIfAvailable) for this sort of info be useful?

I'm not sure if it is worth to do so just yet. Do you anticipate this kind of use-case to become more common?

asbirlea added inline comments.Nov 11 2021, 5:19 PM
llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
1932

I don't have another use case in mind at the moment, so agreed on keeping it as is; the comment is good.

fhahn marked 2 inline comments as done.

ping :)

llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
1932

Thanks, so is this now good as is?

nikic accepted this revision.Nov 30 2021, 6:22 AM

LGTM

This revision is now accepted and ready to land.Nov 30 2021, 6:22 AM
This revision was automatically updated to reflect the committed changes.
fhahn marked an inline comment as done.