diff options
author | Michael Ilseman <milseman@apple.com> | 2012-12-14 22:08:26 +0000 |
---|---|---|
committer | Michael Ilseman <milseman@apple.com> | 2012-12-14 22:08:26 +0000 |
commit | 07acee7a09c4895904f827bf56cf15f6bf8ef9f6 (patch) | |
tree | cafd842626c45de0922e450d9c8ae9f3b509a074 /lib/Transforms/InstCombine/InstCombineAddSub.cpp | |
parent | f53e7cb9b95677dcc2181485fed8cb592056b805 (diff) |
Add back FoldOpIntoPhi optimizations with fix. Included test cases to help catch these errors and to test the presence of the optimization itself
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@170248 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/InstCombine/InstCombineAddSub.cpp')
-rw-r--r-- | lib/Transforms/InstCombine/InstCombineAddSub.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/Transforms/InstCombine/InstCombineAddSub.cpp b/lib/Transforms/InstCombine/InstCombineAddSub.cpp index c22249527b..47223c3b35 100644 --- a/lib/Transforms/InstCombine/InstCombineAddSub.cpp +++ b/lib/Transforms/InstCombine/InstCombineAddSub.cpp @@ -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)) |