summaryrefslogtreecommitdiff
path: root/lib/VMCore/ConstantFold.cpp
diff options
context:
space:
mode:
authorEd Schouten <ed@FreeBSD.org>2009-06-06 08:20:29 +0000
committerEd Schouten <ed@FreeBSD.org>2009-06-06 08:20:29 +0000
commitf4fe016fa15f703fe9c1b932d1e81e2c718521db (patch)
tree8a1bbd1a5b838080d31e5c93a1817006b8c62318 /lib/VMCore/ConstantFold.cpp
parent68eb509bdc5c7007520d5231cd92de28106236df (diff)
Notes
Diffstat (limited to 'lib/VMCore/ConstantFold.cpp')
-rw-r--r--lib/VMCore/ConstantFold.cpp23
1 files changed, 15 insertions, 8 deletions
diff --git a/lib/VMCore/ConstantFold.cpp b/lib/VMCore/ConstantFold.cpp
index 7e4902fd5635..1d293ccbd44d 100644
--- a/lib/VMCore/ConstantFold.cpp
+++ b/lib/VMCore/ConstantFold.cpp
@@ -602,10 +602,8 @@ Constant *llvm::ConstantFoldBinaryInstruction(unsigned Opcode,
return Constant::getNullValue(C1->getType());
case Instruction::UDiv:
case Instruction::SDiv:
- case Instruction::FDiv:
case Instruction::URem:
case Instruction::SRem:
- case Instruction::FRem:
if (!isa<UndefValue>(C2)) // undef / X -> 0
return Constant::getNullValue(C1->getType());
return const_cast<Constant*>(C2); // X / undef -> undef
@@ -783,13 +781,13 @@ Constant *llvm::ConstantFoldBinaryInstruction(unsigned Opcode,
switch (Opcode) {
default:
break;
- case Instruction::Add:
+ case Instruction::FAdd:
(void)C3V.add(C2V, APFloat::rmNearestTiesToEven);
return ConstantFP::get(C3V);
- case Instruction::Sub:
+ case Instruction::FSub:
(void)C3V.subtract(C2V, APFloat::rmNearestTiesToEven);
return ConstantFP::get(C3V);
- case Instruction::Mul:
+ case Instruction::FMul:
(void)C3V.multiply(C2V, APFloat::rmNearestTiesToEven);
return ConstantFP::get(C3V);
case Instruction::FDiv:
@@ -808,12 +806,18 @@ Constant *llvm::ConstantFoldBinaryInstruction(unsigned Opcode,
switch (Opcode) {
default:
break;
- case Instruction::Add:
+ case Instruction::Add:
return EvalVectorOp(CP1, CP2, VTy, ConstantExpr::getAdd);
- case Instruction::Sub:
+ case Instruction::FAdd:
+ return EvalVectorOp(CP1, CP2, VTy, ConstantExpr::getFAdd);
+ case Instruction::Sub:
return EvalVectorOp(CP1, CP2, VTy, ConstantExpr::getSub);
- case Instruction::Mul:
+ case Instruction::FSub:
+ return EvalVectorOp(CP1, CP2, VTy, ConstantExpr::getFSub);
+ case Instruction::Mul:
return EvalVectorOp(CP1, CP2, VTy, ConstantExpr::getMul);
+ case Instruction::FMul:
+ return EvalVectorOp(CP1, CP2, VTy, ConstantExpr::getFMul);
case Instruction::UDiv:
return EvalVectorOp(CP1, CP2, VTy, ConstantExpr::getUDiv);
case Instruction::SDiv:
@@ -851,7 +855,9 @@ Constant *llvm::ConstantFoldBinaryInstruction(unsigned Opcode,
// other way if possible.
switch (Opcode) {
case Instruction::Add:
+ case Instruction::FAdd:
case Instruction::Mul:
+ case Instruction::FMul:
case Instruction::And:
case Instruction::Or:
case Instruction::Xor:
@@ -862,6 +868,7 @@ Constant *llvm::ConstantFoldBinaryInstruction(unsigned Opcode,
case Instruction::LShr:
case Instruction::AShr:
case Instruction::Sub:
+ case Instruction::FSub:
case Instruction::SDiv:
case Instruction::UDiv:
case Instruction::FDiv: