Restore the PHI optimization I accidently removed
authorMichael Ilseman <milseman@apple.com>
Wed, 12 Dec 2012 20:59:36 +0000 (20:59 +0000)
committerMichael Ilseman <milseman@apple.com>
Wed, 12 Dec 2012 20:59:36 +0000 (20:59 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@170024 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/InstCombine/InstCombineAddSub.cpp

index c22249527b9135abb9e95c72098f43c5591ce259..01a3c48635acd4bdba10b26d9c59a79ff15ca7e8 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<PHINode>(LHS))
+    if (Instruction *NV = FoldOpIntoPhi(I))
+      return NV;
+
   // -A + B  -->  B - A
   // -A + -B  -->  -(A + B)
   if (Value *LHSV = dyn_castFNegVal(LHS))