PPU LLVM: fix regression from warning fixes

Forgot that negative power is used here.
This commit is contained in:
Nekotekina 2020-03-05 10:38:47 +03:00
parent f1147f70f4
commit 0a41999818
1 changed files with 16 additions and 1 deletions

View File

@ -230,8 +230,23 @@ Value* PPUTranslator::GetAddr(u64 _add)
Type* PPUTranslator::ScaleType(Type* type, s32 pow2)
{
verify(HERE), (type->getScalarType()->isIntegerTy());
verify(HERE), pow2 > -32, pow2 < 32;
const auto new_type = m_ir->getIntNTy(type->getScalarSizeInBits() * (1 << pow2));
uint scaled = type->getScalarSizeInBits();
verify(HERE), utils::popcnt32(scaled) == 1;
if (pow2 > 0)
{
scaled <<= pow2;
}
else if (pow2 < 0)
{
scaled >>= -pow2;
}
verify(HERE), (scaled != 0);
const auto new_type = m_ir->getIntNTy(scaled);
return type->isVectorTy() ? VectorType::get(new_type, type->getVectorNumElements()) : cast<Type>(new_type);
}