avoid undefined behavior negating minint.

llvm-svn: 110117
This commit is contained in:
Chris Lattner 2010-08-03 16:57:03 +00:00
parent 278008f546
commit 79102d9725
1 changed files with 2 additions and 2 deletions

View File

@ -735,8 +735,8 @@ static void WriteConstants(unsigned FirstVal, unsigned LastVal,
Code = bitc::CST_CODE_UNDEF;
} else if (const ConstantInt *IV = dyn_cast<ConstantInt>(C)) {
if (IV->getBitWidth() <= 64) {
int64_t V = IV->getSExtValue();
if (V >= 0)
uint64_t V = IV->getSExtValue();
if ((int64_t)V >= 0)
Record.push_back(V << 1);
else
Record.push_back((-V << 1) | 1);