summaryrefslogtreecommitdiff
path: root/lib/Transforms/Scalar/JumpThreading.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-11-09 23:00:14 +0000
committerChris Lattner <sabre@nondot.org>2009-11-09 23:00:14 +0000
commit9819ef7742cc2e3af92a0b760fa33e30218ff7bb (patch)
tree56eb2cc549b6aed069f7a5e931fc7921741a388a /lib/Transforms/Scalar/JumpThreading.cpp
parent3f51147d444beb3ecb056df4679b27662095a006 (diff)
downloadllvm-9819ef7742cc2e3af92a0b760fa33e30218ff7bb.tar.gz
llvm-9819ef7742cc2e3af92a0b760fa33e30218ff7bb.tar.bz2
llvm-9819ef7742cc2e3af92a0b760fa33e30218ff7bb.tar.xz
use instructionsimplify instead of a weak clone of ad-hoc folding stuff.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86616 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar/JumpThreading.cpp')
-rw-r--r--lib/Transforms/Scalar/JumpThreading.cpp24
1 files changed, 2 insertions, 22 deletions
diff --git a/lib/Transforms/Scalar/JumpThreading.cpp b/lib/Transforms/Scalar/JumpThreading.cpp
index ae382bfaa4..790aaf5db3 100644
--- a/lib/Transforms/Scalar/JumpThreading.cpp
+++ b/lib/Transforms/Scalar/JumpThreading.cpp
@@ -17,6 +17,7 @@
#include "llvm/LLVMContext.h"
#include "llvm/Pass.h"
#include "llvm/Analysis/ConstantFolding.h"
+#include "llvm/Analysis/InstructionSimplify.h"
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
#include "llvm/Transforms/Utils/Local.h"
#include "llvm/Transforms/Utils/SSAUpdater.h"
@@ -203,7 +204,6 @@ static void RemovePredecessorAndSimplify(BasicBlock *BB, BasicBlock *Pred,
// Remove the entries for Pred from the PHI nodes in BB, but do not simplify
// them down. This will leave us with single entry phi nodes and other phis
// that can be removed.
- //BB->removePredecessor(Pred, true);
BB->removePredecessor(Pred, true);
WeakVH PhiIt = &BB->front();
@@ -266,26 +266,6 @@ void JumpThreading::FindLoopHeaders(Function &F) {
LoopHeaders.insert(const_cast<BasicBlock*>(Edges[i].second));
}
-/// GetResultOfComparison - Given an icmp/fcmp predicate and the left and right
-/// hand sides of the compare instruction, try to determine the result. If the
-/// result can not be determined, a null pointer is returned.
-static Constant *GetResultOfComparison(CmpInst::Predicate pred,
- Value *LHS, Value *RHS) {
- if (Constant *CLHS = dyn_cast<Constant>(LHS))
- if (Constant *CRHS = dyn_cast<Constant>(RHS))
- return ConstantExpr::getCompare(pred, CLHS, CRHS);
-
- if (LHS == RHS)
- if (isa<IntegerType>(LHS->getType()) || isa<PointerType>(LHS->getType())) {
- if (ICmpInst::isTrueWhenEqual(pred))
- return ConstantInt::getTrue(LHS->getContext());
- else
- return ConstantInt::getFalse(LHS->getContext());
- }
- return 0;
-}
-
-
/// ComputeValueKnownInPredecessors - Given a basic block BB and a value V, see
/// if we can infer that the value is a known ConstantInt in any of our
/// predecessors. If so, return the known list of value and pred BB in the
@@ -374,7 +354,7 @@ ComputeValueKnownInPredecessors(Value *V, BasicBlock *BB,PredValueInfo &Result){
Value *LHS = PN->getIncomingValue(i);
Value *RHS = Cmp->getOperand(1)->DoPHITranslation(BB, PredBB);
- Constant *Res = GetResultOfComparison(Cmp->getPredicate(), LHS, RHS);
+ Value *Res = SimplifyCompare(Cmp->getPredicate(), LHS, RHS);
if (Res == 0) continue;
if (isa<UndefValue>(Res))