Skip to content

Commit baca2b3

Browse files
committed
[TSAR, Memory] Update RedundantEdgeEliminationPass.
1 parent 0b46db8 commit baca2b3

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

include/tsar/Transform/IR/RedundantEdgeElimination.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,4 @@ class RedundantEdgeEliminationPass :
4343
bool runOnFunction(Function &F) override;
4444
};
4545
}
46-
#endif//TSAR_REDUNDANT_EDGE_ELIMINATION_H
46+
#endif//TSAR_REDUNDANT_EDGE_ELIMINATION_H

lib/Analysis/Memory/DefinedMemory.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,7 @@ class AddUnknownAccessFunctor :
247247
/// loop nest associated with region `R`, this value will be set to `false`,
248248
/// `true` otherwise.
249249
std::pair<MemoryLocationRange, bool> aggregate(
250-
DFRegion *R, const MemoryLocationRange &Loc,
251-
const ReachDFFwk *Fwk) {
250+
DFRegion *R, const MemoryLocationRange &Loc, const ReachDFFwk *Fwk) {
252251
typedef MemoryLocationRange::Dimension Dimension;
253252
typedef MemoryLocationRange::LocKind LocKind;
254253
typedef ICmpInst::Predicate Predicate;
@@ -438,6 +437,7 @@ std::pair<MemoryLocationRange, bool> aggregate(
438437
FinalSCEV);
439438
}
440439
}
440+
LLVM_DEBUG(dbgs() << "[AGGREGATE] AddRecType: "; C->getType()->dump());
441441
auto ZeroItr = C->evaluateAtIteration(SE->getZero(C->getType()), *SE);
442442
auto IdxExprStep = AddRecStep / LoopStep;
443443
LLVM_DEBUG(dbgs() << "[AGGREGATE] LoopStep: " << LoopStep <<

lib/Transform/IR/RedundantEdgeElimination.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,17 @@ bool RedundantEdgeEliminationPass::runOnFunction(Function &F) {
5353
if (auto *BI = dyn_cast<BranchInst>(TI)) {
5454
LLVM_DEBUG(dbgs() << "[REDUNDANT EDGE] instruction: "; BI->dump());
5555
if (BI->isConditional() && isa<ConstantInt>(BI->getCondition())) {
56+
auto IsCondTrue = !cast<ConstantInt>(BI->getCondition())->equalsInt(0);
57+
BI->getSuccessor(IsCondTrue ? 1 : 0)->removePredecessor(&BB);
5658
ReplaceInstWithInst(
57-
BI, cast<ConstantInt>(BI->getCondition())->equalsInt(0) ?
58-
BranchInst::Create(BI->getSuccessor(1)) :
59-
BranchInst::Create(BI->getSuccessor(0)));
59+
BI, IsCondTrue ?
60+
BranchInst::Create(BI->getSuccessor(0)) :
61+
BranchInst::Create(BI->getSuccessor(1)));
6062
LLVM_DEBUG(dbgs() << "[REDUNDANT EDGE] after: "; BB.dump());
6163
}
6264
}
6365
}
6466
}
6567
LLVM_DEBUG(dbgs() << "[REDUNDANT EDGE]: leave " << F.getName() << "\n");
6668
return true;
67-
}
69+
}

0 commit comments

Comments
 (0)