diff options
Diffstat (limited to 'llvm/lib/Transforms/Scalar/JumpThreading.cpp')
-rw-r--r-- | llvm/lib/Transforms/Scalar/JumpThreading.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Scalar/JumpThreading.cpp b/llvm/lib/Transforms/Scalar/JumpThreading.cpp index 928fa3b..c79e756 100644 --- a/llvm/lib/Transforms/Scalar/JumpThreading.cpp +++ b/llvm/lib/Transforms/Scalar/JumpThreading.cpp @@ -465,6 +465,25 @@ ComputeValueKnownInPredecessors(Value *V, BasicBlock *BB, PredValueInfo &Result, return !Result.empty(); } + // Handle Cast instructions. Only see through Cast when the source operand is + // PHI or Cmp and the source type is i1 to save the compilation time. + if (CastInst *CI = dyn_cast<CastInst>(I)) { + Value *Source = CI->getOperand(0); + if (!Source->getType()->isIntegerTy(1)) + return false; + if (!isa<PHINode>(Source) && !isa<CmpInst>(Source)) + return false; + ComputeValueKnownInPredecessors(Source, BB, Result, Preference, CxtI); + if (Result.empty()) + return false; + + // Convert the known values. + for (auto &R : Result) + R.first = ConstantExpr::getCast(CI->getOpcode(), R.first, CI->getType()); + + return true; + } + PredValueInfoTy LHSVals, RHSVals; // Handle some boolean conditions. |