aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/VMCore/ConstantFold.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/VMCore/ConstantFold.cpp b/lib/VMCore/ConstantFold.cpp
index 98fcf1a32e..8cb1c07453 100644
--- a/lib/VMCore/ConstantFold.cpp
+++ b/lib/VMCore/ConstantFold.cpp
@@ -470,6 +470,13 @@ struct DirectFPRules
(BuiltinType)V2->getValue());
return ConstantClass::get(*Ty, Result);
}
+ static Constant *Div(const ConstantClass *V1, const ConstantClass *V2) {
+ if (V2->isExactlyValue(0.0)) return ConstantClass::get(*Ty, INFINITY);
+ if (V2->isExactlyValue(-0.0)) return ConstantClass::get(*Ty, -INFINITY);
+ if (V2->isNullValue()) return 0;
+ BuiltinType R = (BuiltinType)V1->getValue() / (BuiltinType)V2->getValue();
+ return ConstantClass::get(*Ty, R);
+ }
};