From a26780d808b1cad47687c86bd423fea9b912aa16 Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Wed, 7 Jun 2017 00:58:05 +0000 Subject: [PATCH] [Constants] Use isUIntN/isIntN from MathExtras instead of reimplementing the same code. NFC git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@304856 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/IR/Constants.cpp | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/lib/IR/Constants.cpp b/lib/IR/Constants.cpp index 84a57e593dc..27150a89d9b 100644 --- a/lib/IR/Constants.cpp +++ b/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) { -- 2.50.1