1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-02-01 13:11:39 +01:00

[MergeICmp] Simplify how BCECmpBlock instructions are blacklisted

llvm-svn: 326761
This commit is contained in:
Xin Tong 2018-03-06 02:24:02 +00:00
parent eef730bdf9
commit 3f302eb7ec

View File

@ -159,22 +159,16 @@ class BCECmpBlock {
bool BCECmpBlock::doesOtherWork() const {
AssertConsistent();
// All the instructions we care about in the BCE cmp block.
DenseSet<Instruction *> BlockInsts(
{Lhs_.GEP, Rhs_.GEP, Lhs_.LoadI, Rhs_.LoadI, CmpI, BranchI});
// TODO(courbet): Can we allow some other things ? This is very conservative.
// We might be able to get away with anything does does not have any side
// effects outside of the basic block.
// Note: The GEPs and/or loads are not necessarily in the same block.
for (const Instruction &Inst : *BB) {
if (const auto *const GEP = dyn_cast<GetElementPtrInst>(&Inst)) {
if (!(Lhs_.GEP == GEP || Rhs_.GEP == GEP)) return true;
} else if (const auto *const L = dyn_cast<LoadInst>(&Inst)) {
if (!(Lhs_.LoadI == L || Rhs_.LoadI == L)) return true;
} else if (const auto *const C = dyn_cast<ICmpInst>(&Inst)) {
if (C != CmpI) return true;
} else if (const auto *const Br = dyn_cast<BranchInst>(&Inst)) {
if (Br != BranchI) return true;
} else {
if (!BlockInsts.count(&Inst))
return true;
}
}
return false;
}