]> granicus.if.org Git - llvm/commit
[RISCV] Fix RISCVTTIImpl::getIntImmCost for immediates where getMinSignedBits() > 64
authorAlex Bradbury <asb@lowrisc.org>
Tue, 9 Jul 2019 10:56:18 +0000 (10:56 +0000)
committerAlex Bradbury <asb@lowrisc.org>
Tue, 9 Jul 2019 10:56:18 +0000 (10:56 +0000)
commit2a6ebe9bcc67585fd9c28871528a81c815fe3442
treee908e661e1f25952612c68de4c5a64a306516074
parent697ce1291b7de2c2be2992a4547f02aa4d2281a5
[RISCV] Fix RISCVTTIImpl::getIntImmCost for immediates where getMinSignedBits() > 64

APInt::getSExtValue will assert if getMinSignedBits() > 64. This can happen,
for instance, if examining an i128. Avoid this assertion by checking
Imm.getMinSignedBits() <= 64 before doing
getTLI()->isLegalAddImmediate(Imm.getSExtValue()). We could directly check
getMinSignedBits() <= 12 but it seems better to reuse the isLegalAddImmediate
helper for this.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@365462 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Target/RISCV/RISCVTargetTransformInfo.cpp
test/Transforms/ConstantHoisting/RISCV/immediates.ll