[APFloat] Set losesInfo on no-op convert

losesInfo would be left unset when no conversion needs to be done.  A
caller such as InstCombine's fitsInFPType would then branch on an
uninitialized value.

Caught using valgrind on an out-of-tree target.

Differential Revision: https://reviews.llvm.org/D46645


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@332087 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Sven van Haastregt
2018-05-11 09:45:42 +00:00
parent 4ced77c368
commit 5b80d9d3cd
+3 -1
View File
@@ -4443,8 +4443,10 @@ APFloat::APFloat(const fltSemantics &Semantics, StringRef S)
APFloat::opStatus APFloat::convert(const fltSemantics &ToSemantics,
roundingMode RM, bool *losesInfo) {
if (&getSemantics() == &ToSemantics)
if (&getSemantics() == &ToSemantics) {
*losesInfo = false;
return opOK;
}
if (usesLayout<IEEEFloat>(getSemantics()) &&
usesLayout<IEEEFloat>(ToSemantics))
return U.IEEE.convert(ToSemantics, RM, losesInfo);