llvm.org GIT mirror llvm / 7e8d1e7
Merging r323759: ------------------------------------------------------------------------ r323759 | spatel | 2018-01-30 14:53:59 +0100 (Tue, 30 Jan 2018) | 10 lines [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/branches/release_60@324086 91177308-0d34-0410-b5e6-96231b3b80d8 Hans Wennborg 1 year, 7 months ago
2 changed file(s) with 19 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
11751175 auto *Earlier = dyn_cast(DepWrite);
11761176 auto *Later = dyn_cast(Inst);
11771177 if (Earlier && isa(Earlier->getValueOperand()) &&
1178 Later && isa(Later->getValueOperand())) {
1178 Later && isa(Later->getValueOperand()) &&
1179 memoryIsNotModifiedBetween(Earlier, Later, AA)) {
11791180 // If the store we find is:
11801181 // a) partially overwritten by the store to 'Loc'
11811182 // b) the later store is fully contained in the earlier one and
182182 %xbc = bitcast i32* %x to i8*
183183 store i32 0, i32* %x ; big store of constant
184184 store i8 4, i8* %xbc ; small store with mergeable constant
185 ret void
186 }
187
188 ; We can't eliminate the last store because P and Q may alias.
189
190 define void @PR36129(i32* %P, i32* %Q) {
191 ; CHECK-LABEL: @PR36129(
192 ; CHECK-NEXT: store i32 1, i32* [[P:%.*]]
193 ; CHECK-NEXT: [[P2:%.*]] = bitcast i32* [[P]] to i8*
194 ; CHECK-NEXT: store i32 2, i32* [[Q:%.*]]
195 ; CHECK-NEXT: store i8 3, i8* [[P2]]
196 ; CHECK-NEXT: ret void
197 ;
198 store i32 1, i32* %P
199 %P2 = bitcast i32* %P to i8*
200 store i32 2, i32* %Q
201 store i8 3, i8* %P2
185202 ret void
186203 }
187204