| commit ae5733346f0cc86a82c19fcdc50ce8232fa4777a |
| Author: Arthur Eubanks <aeubanks@google.com> |
| Date: Thu Oct 6 10:29:46 2022 -0700 |
| |
| Revert "[DSE] Eliminate noop store even through has clobbering between LoadI and StoreI" |
| |
| This reverts commit cd8f3e75813995c1d2da35370ffcf5af3aff9c2f. |
| |
| Causes miscompiles, see D132657 |
| |
| diff --git a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp |
| index 0036020dd6ee..93abda04bd8f 100644 |
| --- a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp |
| +++ b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp |
| @@ -1874,23 +1874,8 @@ struct DSEState { |
| // We are searching for the definition of the store's destination. |
| // So, if that is the same definition as the load, then this is a |
| // noop. Otherwise, fail. |
| - if (LoadAccess != Current) { |
| - // This is a potentially clobbering store, but it writes the same |
| - // value, so we can safely ignore it if alignment is as expected. |
| - if (auto *CurrentDef = cast<MemoryDef>(Current)) |
| - if (auto *CurrentStoreI = |
| - dyn_cast_or_null<StoreInst>(CurrentDef->getMemoryInst())) |
| - // Check alignment to ensure load or store does not access at an |
| - // offset. |
| - if (CurrentStoreI->getValueOperand() == LoadI) { |
| - TypeSize StoreSize = DL.getTypeStoreSize(LoadI->getType()); |
| - if (!StoreSize.isScalable() && |
| - std::min(CurrentStoreI->getAlign(), LoadI->getAlign()) >= |
| - StoreSize) |
| - continue; |
| - } |
| + if (LoadAccess != Current) |
| return false; |
| - } |
| } |
| return true; |
| } |