mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-24 22:24:54 +00:00
[ARM64] Fix the cost model for cheap large constants.
Originally the cost model would give up for large constants and just return the maximum cost. This is not what we want for constant hoisting, because some of these constants are large in bitwidth, but are still cheap to materialize. This commit fixes the cost model to either return TCC_Free if the cost cannot be determined, or accurately calculate the cost even for large constants (bitwidth > 128). This fixes <rdar://problem/16591573>. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206100 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -154,7 +154,7 @@ unsigned ARM64TTI::getIntImmCost(const APInt &Imm, Type *Ty) const {
|
||||
assert(Ty->isIntegerTy());
|
||||
|
||||
unsigned BitSize = Ty->getPrimitiveSizeInBits();
|
||||
if (BitSize == 0 || BitSize > 128)
|
||||
if (BitSize == 0)
|
||||
return ~0U;
|
||||
|
||||
// Sign-extend all constants to a multiple of 64-bit.
|
||||
@@ -179,8 +179,10 @@ unsigned ARM64TTI::getIntImmCost(unsigned Opcode, unsigned Idx,
|
||||
assert(Ty->isIntegerTy());
|
||||
|
||||
unsigned BitSize = Ty->getPrimitiveSizeInBits();
|
||||
if (BitSize == 0 || BitSize > 128)
|
||||
return ~0U;
|
||||
// There is no cost model for constants with a bit size of 0. Return TCC_Free
|
||||
// here, so that constant hoisting will ignore this constant.
|
||||
if (BitSize == 0)
|
||||
return TCC_Free;
|
||||
|
||||
unsigned ImmIdx = ~0U;
|
||||
switch (Opcode) {
|
||||
@@ -238,8 +240,10 @@ unsigned ARM64TTI::getIntImmCost(Intrinsic::ID IID, unsigned Idx,
|
||||
assert(Ty->isIntegerTy());
|
||||
|
||||
unsigned BitSize = Ty->getPrimitiveSizeInBits();
|
||||
if (BitSize == 0 || BitSize > 128)
|
||||
return ~0U;
|
||||
// There is no cost model for constants with a bit size of 0. Return TCC_Free
|
||||
// here, so that constant hoisting will ignore this constant.
|
||||
if (BitSize == 0)
|
||||
return TCC_Free;
|
||||
|
||||
switch (IID) {
|
||||
default:
|
||||
|
Reference in New Issue
Block a user