llvm.org GIT mirror llvm / 771594b
[DSE] make sure memory is not modified before partial store merging (PR36129) We missed a critical check in D30703. We must make sure that no intermediate store is sitting between the stores that we want to merge. This should fix: https://bugs.llvm.org/show_bug.cgi?id=36129 Differential Revision: https://reviews.llvm.org/D42663 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@323759 91177308-0d34-0410-b5e6-96231b3b80d8 Sanjay Patel 1 year, 7 months ago
2 changed file(s) with 6 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
11711171 auto *Earlier = dyn_cast(DepWrite);
11721172 auto *Later = dyn_cast(Inst);
11731173 if (Earlier && isa(Earlier->getValueOperand()) &&
1174 Later && isa(Later->getValueOperand())) {
1174 Later && isa(Later->getValueOperand()) &&
1175 memoryIsNotModifiedBetween(Earlier, Later, AA)) {
11751176 // If the store we find is:
11761177 // a) partially overwritten by the store to 'Loc'
11771178 // b) the later store is fully contained in the earlier one and
185185 ret void
186186 }
187187
188 ; FIXME: We can't eliminate the last store because P and Q may alias.
188 ; We can't eliminate the last store because P and Q may alias.
189189
190190 define void @PR36129(i32* %P, i32* %Q) {
191191 ; CHECK-LABEL: @PR36129(
192 ; CHECK-NEXT: store i32 3, i32* [[P:%.*]]
192 ; CHECK-NEXT: store i32 1, i32* [[P:%.*]]
193 ; CHECK-NEXT: [[P2:%.*]] = bitcast i32* [[P]] to i8*
193194 ; CHECK-NEXT: store i32 2, i32* [[Q:%.*]]
195 ; CHECK-NEXT: store i8 3, i8* [[P2]]
194196 ; CHECK-NEXT: ret void
195197 ;
196198 store i32 1, i32* %P