[llvm] r326761 - [MergeICmp] Simplify how BCECmpBlock instructions are blacklisted
Xin Tong via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 5 18:24:02 PST 2018
Author: trentxintong
Date: Mon Mar 5 18:24:02 2018
New Revision: 326761
URL: http://llvm.org/viewvc/llvm-project?rev=326761&view=rev
Log:
[MergeICmp] Simplify how BCECmpBlock instructions are blacklisted
Modified:
llvm/trunk/lib/Transforms/Scalar/MergeICmps.cpp
Modified: llvm/trunk/lib/Transforms/Scalar/MergeICmps.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/MergeICmps.cpp?rev=326761&r1=326760&r2=326761&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/MergeICmps.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/MergeICmps.cpp Mon Mar 5 18:24:02 2018
@@ -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;
}
More information about the llvm-commits
mailing list