summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Scalar/JumpThreading.cpp
diff options
context:
space:
mode:
authorHaicheng Wu <haicheng@codeaurora.org>2016-03-16 04:52:52 +0000
committerHaicheng Wu <haicheng@codeaurora.org>2016-03-16 04:52:52 +0000
commit7873857a8893c17335de7693fea860bdc4b162f0 (patch)
tree16a1d1889d9690f2493c3af1fc482ef614eb3426 /llvm/lib/Transforms/Scalar/JumpThreading.cpp
parentc9daaaedb67e1e0265f795f8a9cbad6bc9553883 (diff)
downloadbcm5719-llvm-7873857a8893c17335de7693fea860bdc4b162f0.tar.gz
bcm5719-llvm-7873857a8893c17335de7693fea860bdc4b162f0.zip
[JumpThreading] See through Cast Instructions
To capture more jump-thread opportunity. llvm-svn: 263618
Diffstat (limited to 'llvm/lib/Transforms/Scalar/JumpThreading.cpp')
-rw-r--r--llvm/lib/Transforms/Scalar/JumpThreading.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Scalar/JumpThreading.cpp b/llvm/lib/Transforms/Scalar/JumpThreading.cpp
index 928fa3b1c6a..c79e756f572 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.
OpenPOWER on IntegriCloud