diff options
author | Eli Friedman <efriedma@codeaurora.org> | 2018-06-14 22:58:48 +0000 |
---|---|---|
committer | Eli Friedman <efriedma@codeaurora.org> | 2018-06-14 22:58:48 +0000 |
commit | 3f1ce093ea4dd86c50ececa1da85edb78b904e72 (patch) | |
tree | f50336563a7d7fe394368d5f5e555e7c3c099e46 /llvm/lib/IR/ConstantFold.cpp | |
parent | 9afe1fa7e295d31ecdaed5ab33bf3e5bbb804f40 (diff) | |
download | llvm-3f1ce093ea4dd86c50ececa1da85edb78b904e72.zip llvm-3f1ce093ea4dd86c50ececa1da85edb78b904e72.tar.gz llvm-3f1ce093ea4dd86c50ececa1da85edb78b904e72.tar.bz2 |
Make uitofp and sitofp defined on overflow.
IEEE 754 defines the expected result on overflow. As far as I know,
hardware implementations (of f16), and compiler-rt (__floatuntisf)
correctly return +-Inf on overflow. And I can't think of any useful
transform that would take advantage of overflow being undefined here.
Differential Revision: https://reviews.llvm.org/D47807
llvm-svn: 334777
Diffstat (limited to 'llvm/lib/IR/ConstantFold.cpp')
-rw-r--r-- | llvm/lib/IR/ConstantFold.cpp | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/llvm/lib/IR/ConstantFold.cpp b/llvm/lib/IR/ConstantFold.cpp index 218adb4..514a534 100644 --- a/llvm/lib/IR/ConstantFold.cpp +++ b/llvm/lib/IR/ConstantFold.cpp @@ -682,13 +682,8 @@ Constant *llvm::ConstantFoldCastInstruction(unsigned opc, Constant *V, const APInt &api = CI->getValue(); APFloat apf(DestTy->getFltSemantics(), APInt::getNullValue(DestTy->getPrimitiveSizeInBits())); - if (APFloat::opOverflow & - apf.convertFromAPInt(api, opc==Instruction::SIToFP, - APFloat::rmNearestTiesToEven)) { - // Undefined behavior invoked - the destination type can't represent - // the input constant. - return UndefValue::get(DestTy); - } + apf.convertFromAPInt(api, opc==Instruction::SIToFP, + APFloat::rmNearestTiesToEven); return ConstantFP::get(V->getContext(), apf); } return nullptr; |