llvm.org GIT mirror llvm / 4d0342f
perform DSE through launder.invariant.group Summary: Alias Analysis knows that llvm.launder.invariant.group returns pointer that mustalias argument, but this information wasn't used, therefor we didn't DSE through launder.invariant.group Reviewers: chandlerc, dberlin, bogner, hfinkel, efriedma Reviewed By: dberlin Subscribers: amharc, llvm-commits, nlewycky, rsmith Differential Revision: https://reviews.llvm.org/D31581 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331449 91177308-0d34-0410-b5e6-96231b3b80d8 Piotr Padlewski 1 year, 4 months ago
2 changed file(s) with 35 addition(s) and 5 deletion(s). Raw diff Collapse all Expand all
342342 const TargetLibraryInfo &TLI,
343343 int64_t &EarlierOff, int64_t &LaterOff,
344344 Instruction *DepWrite,
345 InstOverlapIntervalsTy &IOL) {
345 InstOverlapIntervalsTy &IOL,
346 AliasAnalysis &AA) {
346347 // If we don't know the sizes of either access, then we can't do a comparison.
347348 if (Later.Size == MemoryLocation::UnknownSize ||
348349 Earlier.Size == MemoryLocation::UnknownSize)
353354
354355 // If the start pointers are the same, we just have to compare sizes to see if
355356 // the later store was larger than the earlier store.
356 if (P1 == P2) {
357 if (P1 == P2 || AA.isMustAlias(P1, P2)) {
357358 // Make sure that the Later size is >= the Earlier size.
358359 if (Later.Size >= Earlier.Size)
359360 return OW_Complete;
11611162 if (isRemovable(DepWrite) &&
11621163 !isPossibleSelfRead(Inst, Loc, DepWrite, *TLI, *AA)) {
11631164 int64_t InstWriteOffset, DepWriteOffset;
1164 OverwriteResult OR =
1165 isOverwrite(Loc, DepLoc, DL, *TLI, DepWriteOffset, InstWriteOffset,
1166 DepWrite, IOL);
1165 OverwriteResult OR = isOverwrite(Loc, DepLoc, DL, *TLI, DepWriteOffset,
1166 InstWriteOffset, DepWrite, IOL, *AA);
11671167 if (OR == OW_Complete) {
11681168 DEBUG(dbgs() << "DSE: Remove Dead Store:\n DEAD: "
11691169 << *DepWrite << "\n KILLER: " << *Inst << '\n');
0 ; RUN: opt < %s -basicaa -dse -S | FileCheck %s
1
2 ; CHECK-LABEL: void @skipBarrier(i8* %ptr)
3 define void @skipBarrier(i8* %ptr) {
4 ; CHECK-NOT: store i8 42
5 store i8 42, i8* %ptr
6 ; CHECK: %ptr2 = call i8* @llvm.launder.invariant.group.p0i8(i8* %ptr)
7 %ptr2 = call i8* @llvm.launder.invariant.group.p0i8(i8* %ptr)
8 ; CHECK: store i8 43
9 store i8 43, i8* %ptr2
10 ret void
11 }
12
13 ; CHECK-LABEL: void @skip2Barriers(i8* %ptr)
14 define void @skip2Barriers(i8* %ptr) {
15 ; CHECK-NOT: store i8 42
16 store i8 42, i8* %ptr
17 ; CHECK: %ptr2 = call i8* @llvm.launder.invariant.group.p0i8(i8* %ptr)
18 %ptr2 = call i8* @llvm.launder.invariant.group.p0i8(i8* %ptr)
19 ; CHECK-NOT: store i8 43
20 store i8 43, i8* %ptr2
21 %ptr3 = call i8* @llvm.launder.invariant.group.p0i8(i8* %ptr2)
22 %ptr4 = call i8* @llvm.launder.invariant.group.p0i8(i8* %ptr3)
23
24 ; CHECK: store i8 44
25 store i8 44, i8* %ptr4
26 ret void
27 }
28
29 declare i8* @llvm.launder.invariant.group.p0i8(i8*)