forked from OSchip/llvm-project
Revert "[DSE] Eliminate noop store even through has clobbering between LoadI and StoreI"
This reverts commit cd8f3e7581
.
Causes miscompiles, see D132657
This commit is contained in:
parent
5922b92060
commit
ae5733346f
|
@ -1874,24 +1874,9 @@ 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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -672,6 +672,7 @@ define void @store_same_i32_to_mayalias_loc(ptr %q, ptr %p) {
|
|||
; CHECK-LABEL: @store_same_i32_to_mayalias_loc(
|
||||
; CHECK-NEXT: [[V:%.*]] = load i32, ptr [[P:%.*]], align 4
|
||||
; CHECK-NEXT: store i32 [[V]], ptr [[Q:%.*]], align 4
|
||||
; CHECK-NEXT: store i32 [[V]], ptr [[P]], align 4
|
||||
; CHECK-NEXT: ret void
|
||||
;
|
||||
%v = load i32, ptr %p, align 4
|
||||
|
@ -697,6 +698,7 @@ define void @store_same_i12_to_mayalias_loc(ptr %q, ptr %p) {
|
|||
; CHECK-LABEL: @store_same_i12_to_mayalias_loc(
|
||||
; CHECK-NEXT: [[V:%.*]] = load i12, ptr [[P:%.*]], align 2
|
||||
; CHECK-NEXT: store i12 [[V]], ptr [[Q:%.*]], align 2
|
||||
; CHECK-NEXT: store i12 [[V]], ptr [[P]], align 2
|
||||
; CHECK-NEXT: ret void
|
||||
;
|
||||
%v = load i12, ptr %p, align 2
|
||||
|
@ -722,6 +724,7 @@ define void @store_same_ptr_to_mayalias_loc(ptr %q, ptr %p) {
|
|||
; CHECK-LABEL: @store_same_ptr_to_mayalias_loc(
|
||||
; CHECK-NEXT: [[V:%.*]] = load ptr, ptr [[P:%.*]], align 8
|
||||
; CHECK-NEXT: store ptr [[V]], ptr [[Q:%.*]], align 8
|
||||
; CHECK-NEXT: store ptr [[V]], ptr [[P]], align 8
|
||||
; CHECK-NEXT: ret void
|
||||
;
|
||||
%v = load ptr, ptr %p, align 8
|
||||
|
|
|
@ -594,6 +594,7 @@ define void @pr49927(ptr %q, ptr %p) {
|
|||
; CHECK-LABEL: @pr49927(
|
||||
; CHECK-NEXT: [[V:%.*]] = load i32, ptr [[P:%.*]], align 4
|
||||
; CHECK-NEXT: store i32 [[V]], ptr [[Q:%.*]], align 4
|
||||
; CHECK-NEXT: store i32 [[V]], ptr [[P]], align 4
|
||||
; CHECK-NEXT: ret void
|
||||
;
|
||||
%v = load i32, ptr %p, align 4
|
||||
|
|
Loading…
Reference in New Issue