diff options
| author | Andrew Lenharth <andrewl@lenharth.org> | 2005-05-02 21:25:47 +0000 |
|---|---|---|
| committer | Andrew Lenharth <andrewl@lenharth.org> | 2005-05-02 21:25:47 +0000 |
| commit | c73e633a416fdcec7f3682b04f5af78e147ef30c (patch) | |
| tree | c31954ced2fab1f5e729686bf23a648a5443f1f1 /llvm/lib/VMCore | |
| parent | f5d58d1bc375c2b6bd8971b2ee58d8fc77d66a11 (diff) | |
| download | bcm5719-llvm-c73e633a416fdcec7f3682b04f5af78e147ef30c.tar.gz bcm5719-llvm-c73e633a416fdcec7f3682b04f5af78e147ef30c.zip | |
fold fp div by 0 to inf, the way gcc does. This is legal according to the FP spec
llvm-svn: 21655
Diffstat (limited to 'llvm/lib/VMCore')
| -rw-r--r-- | llvm/lib/VMCore/ConstantFolding.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/llvm/lib/VMCore/ConstantFolding.cpp b/llvm/lib/VMCore/ConstantFolding.cpp index 98fcf1a32e4..8cb1c074534 100644 --- a/llvm/lib/VMCore/ConstantFolding.cpp +++ b/llvm/lib/VMCore/ConstantFolding.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); + } }; |

