llvm.org GIT mirror llvm / ea02a02
[EarlyCSE] Make PhiToCheck in removeMSSA() a set. This way we end up not looking at PHI args already removed. MemSSA now goes through the updater so we can prune it to avoid having redundant MemoryPHI arguments, but that doesn't quite work for the general case. Discussed with Daniel Berlin, fixes PR33406. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@305409 91177308-0d34-0410-b5e6-96231b3b80d8 Davide Italiano 2 years ago
2 changed file(s) with 29 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
1414 #include "llvm/Transforms/Scalar/EarlyCSE.h"
1515 #include "llvm/ADT/Hashing.h"
1616 #include "llvm/ADT/ScopedHashTable.h"
17 #include "llvm/ADT/SetVector.h"
1718 #include "llvm/ADT/Statistic.h"
1819 #include "llvm/Analysis/AssumptionCache.h"
1920 #include "llvm/Analysis/GlobalsModRef.h"
505506 if (MemoryAccess *MA = MSSA->getMemoryAccess(Inst)) {
506507 // Optimize MemoryPhi nodes that may become redundant by having all the
507508 // same input values once MA is removed.
508 SmallVector PhisToCheck;
509 SmallSetVector PhisToCheck;
509510 SmallVector WorkQueue;
510511 WorkQueue.push_back(MA);
511512 // Process MemoryPhi nodes in FIFO order using a ever-growing vector since
516517
517518 for (auto *U : WI->users())
518519 if (MemoryPhi *MP = dyn_cast(U))
519 PhisToCheck.push_back(MP);
520 PhisToCheck.insert(MP);
520521
521522 MSSAUpdater->removeMemoryAccess(WI);
522523
0 ; RUN: opt -early-cse-memssa -S %s | FileCheck %s
1
2 ; CHECK: define void @patatino() {
3 ; CHECK: for.cond:
4 ; CHECK-NEXT: br i1 true, label %if.end, label %for.inc
5 ; CHECK: if.end:
6 ; CHECK-NEXT: %tinkywinky = load i32, i32* @b
7 ; CHECK-NEXT: br i1 true, label %for.inc, label %for.inc
8 ; CHECK: for.inc:
9 ; CHECK-NEXT: ret void
10
11
12 @b = external global i32
13
14 define void @patatino() {
15 for.cond:
16 br i1 true, label %if.end, label %for.inc
17
18 if.end:
19 %tinkywinky = load i32, i32* @b
20 store i32 %tinkywinky, i32* @b
21 br i1 true, label %for.inc, label %for.inc
22
23 for.inc:
24 ret void
25 }