diff options
author | Owen Anderson <resistor@mac.com> | 2014-01-16 21:26:02 +0000 |
---|---|---|
committer | Owen Anderson <resistor@mac.com> | 2014-01-16 21:26:02 +0000 |
commit | 5ee5e0c4305fd6a1870bfc9d4fc82bf96f2d499e (patch) | |
tree | 79cd83ee5d49750af06faa6135eb965f5397da3d /lib | |
parent | 5d9450f92f559bec20ef2ce253ab7bdf5e75216b (diff) | |
download | llvm-5ee5e0c4305fd6a1870bfc9d4fc82bf96f2d499e.tar.gz llvm-5ee5e0c4305fd6a1870bfc9d4fc82bf96f2d499e.tar.bz2 llvm-5ee5e0c4305fd6a1870bfc9d4fc82bf96f2d499e.tar.xz |
Fix two cases where we could lose fast math flags when optimizing FADD expressions.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199427 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Transforms/InstCombine/InstCombineAddSub.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/Transforms/InstCombine/InstCombineAddSub.cpp b/lib/Transforms/InstCombine/InstCombineAddSub.cpp index 534feb8fad..d49153e482 100644 --- a/lib/Transforms/InstCombine/InstCombineAddSub.cpp +++ b/lib/Transforms/InstCombine/InstCombineAddSub.cpp @@ -1198,13 +1198,19 @@ Instruction *InstCombiner::visitFAdd(BinaryOperator &I) { // -A + B --> B - A // -A + -B --> -(A + B) - if (Value *LHSV = dyn_castFNegVal(LHS)) - return BinaryOperator::CreateFSub(RHS, LHSV); + if (Value *LHSV = dyn_castFNegVal(LHS)) { + Instruction *RI = BinaryOperator::CreateFSub(RHS, LHSV); + RI->copyFastMathFlags(&I); + return RI; + } // A + -B --> A - B if (!isa<Constant>(RHS)) - if (Value *V = dyn_castFNegVal(RHS)) - return BinaryOperator::CreateFSub(LHS, V); + if (Value *V = dyn_castFNegVal(RHS)) { + Instruction *RI = BinaryOperator::CreateFSub(LHS, V); + RI->copyFastMathFlags(&I); + return RI; + } // Check for (fadd double (sitofp x), y), see if we can merge this into an // integer add followed by a promotion. |