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
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 @@
       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 @@
   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;
     }