diff options
author | Dale Johannesen <dalej@apple.com> | 2010-10-27 23:45:18 +0000 |
---|---|---|
committer | Dale Johannesen <dalej@apple.com> | 2010-10-27 23:45:18 +0000 |
commit | f514f5279043652a8ac915e8e3c176d53980a128 (patch) | |
tree | e6b874854ce5893b81fa1c55354d12ab7b6be72a /lib/Transforms/InstCombine/InstCombineSelect.cpp | |
parent | f40deed62f4f0126459ed7bfd1799f4e09b1aaa7 (diff) |
Teach InstCombine not to use Add and Neg on FP. PR 8490.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@117510 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/InstCombine/InstCombineSelect.cpp')
-rw-r--r-- | lib/Transforms/InstCombine/InstCombineSelect.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/Transforms/InstCombine/InstCombineSelect.cpp b/lib/Transforms/InstCombine/InstCombineSelect.cpp index c44fe9db6e..2cbb810fc1 100644 --- a/lib/Transforms/InstCombine/InstCombineSelect.cpp +++ b/lib/Transforms/InstCombine/InstCombineSelect.cpp @@ -639,6 +639,10 @@ Instruction *InstCombiner::visitSelectInst(SelectInst &SI) { Value *NegVal; // Compute -Z if (Constant *C = dyn_cast<Constant>(SubOp->getOperand(1))) { NegVal = ConstantExpr::getNeg(C); + } else if (SI.getType()->isFloatingPointTy()) { + NegVal = InsertNewInstBefore( + BinaryOperator::CreateFNeg(SubOp->getOperand(1), + "tmp"), SI); } else { NegVal = InsertNewInstBefore( BinaryOperator::CreateNeg(SubOp->getOperand(1), @@ -654,7 +658,10 @@ Instruction *InstCombiner::visitSelectInst(SelectInst &SI) { NewFalseOp, SI.getName() + ".p"); NewSel = InsertNewInstBefore(NewSel, SI); - return BinaryOperator::CreateAdd(SubOp->getOperand(0), NewSel); + if (SI.getType()->isFloatingPointTy()) + return BinaryOperator::CreateFAdd(SubOp->getOperand(0), NewSel); + else + return BinaryOperator::CreateAdd(SubOp->getOperand(0), NewSel); } } } |