This is an archive of the discontinued LLVM Phabricator instance.

[DAG] Elide stores which are overwritten without being observed.
ClosedPublic

Authored by niravd on May 15 2017, 11:06 AM.

Details

Summary

In SelectionDAG, when a store is immediately chained to another store
to the same address, elide the first store as it has no observable
effects. This is causes small improvements dealing with intrinsics
lowered to stores.

Test notes:

  • Many testcases overwrite store addresses multiple times and needed minor changes, mainly making stores volatile to prevent the optimization from optimizing the test away.
  • Many X86 test cases optimized out instructions associated with associated with va_start.
  • Note that test_splat in CodeGen/AArch64/misched-stp.ll no longer has dependencies to check and can probably be removed and potentially replaced with another test.

Diff Detail

Repository
rL LLVM

Event Timeline

niravd created this revision.May 15 2017, 11:06 AM
rnk added inline comments.May 15 2017, 1:39 PM
lib/CodeGen/SelectionDAG/DAGCombiner.cpp
13132 ↗(On Diff #99027)

What do you think of moving this logic in here so that we don't need two ST1 dyn_casts? It'd look like:

if (ST1->getBasePtr() == Ptr && ST->getMemoryVT() == ST1->getMemoryVT() &&
    ST->isUnindexed() && !ST->isVolatile() &&
    ST1->isUnindexed() && !ST1->isVolatile()) {
  if (ST1->getValue() == Value) { ... }
  else if (OptLevel != CodeGenOpt::None && ST1->hasOneUse() && !ST1->getPasePtr().isUndef()) { ... }
}
niravd updated this revision to Diff 99153.May 16 2017, 9:09 AM

Rebasing past visitTokenFactor cleanup and do Reid's suggested cleanup

niravd marked an inline comment as done.May 16 2017, 9:10 AM
rnk accepted this revision.May 16 2017, 12:46 PM

lgtm, thanks!

This revision is now accepted and ready to land.May 16 2017, 12:46 PM
This revision was automatically updated to reflect the committed changes.