diff options
Diffstat (limited to 'llvm/lib/Transforms/AggressiveInstCombine/TruncInstCombine.cpp')
-rw-r--r-- | llvm/lib/Transforms/AggressiveInstCombine/TruncInstCombine.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/AggressiveInstCombine/TruncInstCombine.cpp b/llvm/lib/Transforms/AggressiveInstCombine/TruncInstCombine.cpp index deb0979265c..0378ea79ef7 100644 --- a/llvm/lib/Transforms/AggressiveInstCombine/TruncInstCombine.cpp +++ b/llvm/lib/Transforms/AggressiveInstCombine/TruncInstCombine.cpp @@ -31,6 +31,7 @@ #include "llvm/Analysis/ConstantFolding.h" #include "llvm/Analysis/TargetLibraryInfo.h" #include "llvm/IR/DataLayout.h" +#include "llvm/IR/Dominators.h" #include "llvm/IR/IRBuilder.h" using namespace llvm; @@ -380,10 +381,14 @@ bool TruncInstCombine::run(Function &F) { bool MadeIRChange = false; // Collect all TruncInst in the function into the Worklist for evaluating. - for (auto &BB : F) + for (auto &BB : F) { + // Ignore unreachable basic block. + if (!DT.isReachableFromEntry(&BB)) + continue; for (auto &I : BB) if (auto *CI = dyn_cast<TruncInst>(&I)) Worklist.push_back(CI); + } // Process all TruncInst in the Worklist, for each instruction: // 1. Check if it dominates an eligible expression dag to be reduced. |