diff options
author | Craig Topper <craig.topper@gmail.com> | 2017-06-07 00:58:05 +0000 |
---|---|---|
committer | Craig Topper <craig.topper@gmail.com> | 2017-06-07 00:58:05 +0000 |
commit | 50b1e5135ef0a2a7667da0079f4ebf14582ef543 (patch) | |
tree | 2a5bc87a2791c9da4d4e69e5afe9179f3822e27a /llvm/lib | |
parent | 93ac6e14cd3abd216096db95440c93b9cb9cceba (diff) | |
download | bcm5719-llvm-50b1e5135ef0a2a7667da0079f4ebf14582ef543.tar.gz bcm5719-llvm-50b1e5135ef0a2a7667da0079f4ebf14582ef543.zip |
[Constants] Use isUIntN/isIntN from MathExtras instead of reimplementing the same code. NFC
llvm-svn: 304856
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/IR/Constants.cpp | 11 |
1 files changed, 2 insertions, 9 deletions
diff --git a/llvm/lib/IR/Constants.cpp b/llvm/lib/IR/Constants.cpp index 84a57e593dc..27150a89d9b 100644 --- a/llvm/lib/IR/Constants.cpp +++ b/llvm/lib/IR/Constants.cpp @@ -1157,21 +1157,14 @@ bool ConstantInt::isValueValidForType(Type *Ty, uint64_t Val) { unsigned NumBits = Ty->getIntegerBitWidth(); // assert okay if (Ty->isIntegerTy(1)) return Val == 0 || Val == 1; - if (NumBits >= 64) - return true; // always true, has to fit in largest type - uint64_t Max = (1ll << NumBits) - 1; - return Val <= Max; + return isUIntN(NumBits, Val); } bool ConstantInt::isValueValidForType(Type *Ty, int64_t Val) { unsigned NumBits = Ty->getIntegerBitWidth(); if (Ty->isIntegerTy(1)) return Val == 0 || Val == 1 || Val == -1; - if (NumBits >= 64) - return true; // always true, has to fit in largest type - int64_t Min = -(1ll << (NumBits-1)); - int64_t Max = (1ll << (NumBits-1)) - 1; - return (Val >= Min && Val <= Max); + return isIntN(NumBits, Val); } bool ConstantFP::isValueValidForType(Type *Ty, const APFloat& Val) { |