aboutsummaryrefslogtreecommitdiff
path: root/lib/VMCore/ConstantFold.cpp
diff options
context:
space:
mode:
authorAndrew Lenharth <andrewl@lenharth.org>2005-05-02 21:25:47 +0000
committerAndrew Lenharth <andrewl@lenharth.org>2005-05-02 21:25:47 +0000
commit8b9e3e651159653a98141ea89ba35305d7f8c7e2 (patch)
tree28cce9fb107308f77be94a914544fa7f856e7229 /lib/VMCore/ConstantFold.cpp
parentabc73b3e5dfb5f8b3f82068d20b419067a5797a1 (diff)
fold fp div by 0 to inf, the way gcc does. This is legal according to the FP spec
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21655 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/ConstantFold.cpp')
-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);
+ }
};