aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Transforms
diff options
context:
space:
mode:
authorDale Johannesen <dalej@apple.com>2010-10-27 23:45:18 +0000
committerDale Johannesen <dalej@apple.com>2010-10-27 23:45:18 +0000
commitf514f5279043652a8ac915e8e3c176d53980a128 (patch)
treee6b874854ce5893b81fa1c55354d12ab7b6be72a /lib/Transforms
parentf40deed62f4f0126459ed7bfd1799f4e09b1aaa7 (diff)
downloadexternal_llvm-f514f5279043652a8ac915e8e3c176d53980a128.zip
external_llvm-f514f5279043652a8ac915e8e3c176d53980a128.tar.gz
external_llvm-f514f5279043652a8ac915e8e3c176d53980a128.tar.bz2
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')
-rw-r--r--lib/Transforms/InstCombine/InstCombineSelect.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/Transforms/InstCombine/InstCombineSelect.cpp b/lib/Transforms/InstCombine/InstCombineSelect.cpp
index c44fe9d..2cbb810 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);
}
}
}