diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2018-12-19 22:09:02 +0000 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2018-12-19 22:09:02 +0000 |
commit | 3817ee7908346a9a900a04baacd64f828e9e9ef0 (patch) | |
tree | 1079c1a2c00daa2ca932f0f13cb6a35cf225aaeb /llvm/lib/Transforms | |
parent | a749d602b54296ee6d4068fe6e6bb805b204263d (diff) | |
download | bcm5719-llvm-3817ee7908346a9a900a04baacd64f828e9e9ef0.tar.gz bcm5719-llvm-3817ee7908346a9a900a04baacd64f828e9e9ef0.zip |
Revert "[BDCE][DemandedBits] Detect dead uses of undead instructions"
This reverts commit r349674. It causes a failure in
test-suite enc-3des.execution_time.
llvm-svn: 349684
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r-- | llvm/lib/Transforms/Scalar/BDCE.cpp | 38 |
1 files changed, 15 insertions, 23 deletions
diff --git a/llvm/lib/Transforms/Scalar/BDCE.cpp b/llvm/lib/Transforms/Scalar/BDCE.cpp index 65a68c17977..f63182e57c1 100644 --- a/llvm/lib/Transforms/Scalar/BDCE.cpp +++ b/llvm/lib/Transforms/Scalar/BDCE.cpp @@ -96,38 +96,30 @@ static bool bitTrackingDCE(Function &F, DemandedBits &DB) { if (I.mayHaveSideEffects() && I.use_empty()) continue; - // Remove instructions not reached during analysis. - if (DB.isInstructionDead(&I)) { - salvageDebugInfo(I); - Worklist.push_back(&I); - I.dropAllReferences(); - Changed = true; - continue; - } - - for (Use &U : I.operands()) { - // DemandedBits only detects dead integer uses. - if (!U->getType()->isIntOrIntVectorTy()) - continue; - - // TODO: We could also find dead non-instruction uses, e.g. arguments. - if (!isa<Instruction>(U)) - continue; - - if (!DB.isUseDead(&U)) - continue; - - LLVM_DEBUG(dbgs() << "BDCE: Trivializing: " << U << " (all bits dead)\n"); + if (I.getType()->isIntOrIntVectorTy() && + !DB.getDemandedBits(&I).getBoolValue()) { + // For live instructions that have all dead bits, first make them dead by + // replacing all uses with something else. Then, if they don't need to + // remain live (because they have side effects, etc.) we can remove them. + LLVM_DEBUG(dbgs() << "BDCE: Trivializing: " << I << " (all bits dead)\n"); clearAssumptionsOfUsers(&I, DB); // FIXME: In theory we could substitute undef here instead of zero. // This should be reconsidered once we settle on the semantics of // undef, poison, etc. - U.set(ConstantInt::get(U->getType(), 0)); + Value *Zero = ConstantInt::get(I.getType(), 0); ++NumSimplified; + I.replaceNonMetadataUsesWith(Zero); Changed = true; } + if (!DB.isInstructionDead(&I)) + continue; + + salvageDebugInfo(I); + Worklist.push_back(&I); + I.dropAllReferences(); + Changed = true; } for (Instruction *&I : Worklist) { |