diff options
author | Artur Pilipenko <apilipenko@azulsystems.com> | 2017-04-22 07:24:52 +0000 |
---|---|---|
committer | Artur Pilipenko <apilipenko@azulsystems.com> | 2017-04-22 07:24:52 +0000 |
commit | 0632bdc6483dabd0f37134cc8d69bc102e93b213 (patch) | |
tree | afb331dd1572163310db4612953f000b15aea825 /llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp | |
parent | 5e113742e7f02c276e5a3c9d241c181e6d6ec7ff (diff) | |
download | bcm5719-llvm-0632bdc6483dabd0f37134cc8d69bc102e93b213.tar.gz bcm5719-llvm-0632bdc6483dabd0f37134cc8d69bc102e93b213.zip |
Fix for PR32740 - Invalid floating type, unreachable between r300969 and r301029
The bug was introduced by r301018 "[InstCombine] fadd double (sitofp x), y check that the promotion is valid". The patch didn't expect that fadd can be on vectors not necessarily scalars. Add vector support along with the test.
llvm-svn: 301070
Diffstat (limited to 'llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp')
-rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp b/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp index 99c90b8ff49..05f34e9eaa0 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp @@ -1391,11 +1391,14 @@ Instruction *InstCombiner::visitFAdd(BinaryOperator &I) { // analysis can tell us that the result of the addition has less significant // bits than the integer type can hold. auto IsValidPromotion = [](Type *FTy, Type *ITy) { + Type *FScalarTy = FTy->getScalarType(); + Type *IScalarTy = ITy->getScalarType(); + // Do we have enough bits in the significand to represent the result of // the integer addition? unsigned MaxRepresentableBits = - APFloat::semanticsPrecision(FTy->getFltSemantics()); - return ITy->getIntegerBitWidth() <= MaxRepresentableBits; + APFloat::semanticsPrecision(FScalarTy->getFltSemantics()); + return IScalarTy->getIntegerBitWidth() <= MaxRepresentableBits; }; // (fadd double (sitofp x), fpcst) --> (sitofp (add int x, intcst)) |