Add back FoldOpIntoPhi optimizations with fix. Included test cases to help catch...
[oota-llvm.git] / lib / Transforms / InstCombine / InstCombineAddSub.cpp
index c22249527b9135abb9e95c72098f43c5591ce259..47223c3b3588807888943dd71faa4277dfac9fe8 100644 (file)
@@ -354,6 +354,10 @@ Instruction *InstCombiner::visitFAdd(BinaryOperator &I) {
   if (Value *V = SimplifyFAddInst(LHS, RHS, I.getFastMathFlags(), TD))
     return ReplaceInstUsesWith(I, V);
 
+  if (isa<Constant>(RHS) && isa<PHINode>(LHS))
+    if (Instruction *NV = FoldOpIntoPhi(I))
+      return NV;
+
   // -A + B  -->  B - A
   // -A + -B  -->  -(A + B)
   if (Value *LHSV = dyn_castFNegVal(LHS))