diff options
author | Chris Lattner <sabre@nondot.org> | 2009-11-10 01:08:51 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-11-10 01:08:51 +0000 |
commit | e34537856a544c83513e390ac9552a8bc3823346 (patch) | |
tree | 22c3def24ccc951dc07bb42f4eff7ed067705530 /lib/Transforms/Scalar | |
parent | 81cf4325698b48b02eddab921ac333c7f25005c3 (diff) | |
download | external_llvm-e34537856a544c83513e390ac9552a8bc3823346.zip external_llvm-e34537856a544c83513e390ac9552a8bc3823346.tar.gz external_llvm-e34537856a544c83513e390ac9552a8bc3823346.tar.bz2 |
add a new SimplifyInstruction API, which is like ConstantFoldInstruction,
except that the result may not be a constant. Switch jump threading to
use it so that it gets things like (X & 0) -> 0, which occur when phi preds
are deleted and the remaining phi pred was a zero.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86637 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar')
-rw-r--r-- | lib/Transforms/Scalar/JumpThreading.cpp | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/lib/Transforms/Scalar/JumpThreading.cpp b/lib/Transforms/Scalar/JumpThreading.cpp index 7eaae9b..46d40ef 100644 --- a/lib/Transforms/Scalar/JumpThreading.cpp +++ b/lib/Transforms/Scalar/JumpThreading.cpp @@ -16,7 +16,6 @@ #include "llvm/IntrinsicInst.h" #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" @@ -223,9 +222,9 @@ static void RemovePredecessorAndSimplify(BasicBlock *BB, BasicBlock *Pred, Instruction *User = cast<Instruction>(U.getUser()); U = PNV; - // See if we can simplify it (constant folding). - if (Constant *C = ConstantFoldInstruction(User, TD)) { - User->replaceAllUsesWith(C); + // See if we can simplify it. + if (Value *V = SimplifyInstruction(User, TD)) { + User->replaceAllUsesWith(V); User->eraseFromParent(); } } @@ -1203,8 +1202,8 @@ bool JumpThreading::ThreadEdge(BasicBlock *BB, BI = NewBB->begin(); for (BasicBlock::iterator E = NewBB->end(); BI != E; ) { Instruction *Inst = BI++; - if (Constant *C = ConstantFoldInstruction(Inst, TD)) { - Inst->replaceAllUsesWith(C); + if (Value *V = SimplifyInstruction(Inst, TD)) { + Inst->replaceAllUsesWith(V); Inst->eraseFromParent(); continue; } |