Skip to content

Commit c978d05

Browse files
committed
[X86] getIntImmCostInst - pull out repeated Imm.getBitWidth() calls. NFC.
1 parent 9a222a1 commit c978d05

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

llvm/lib/Target/X86/X86TargetTransformInfo.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5788,6 +5788,8 @@ InstructionCost X86TTIImpl::getIntImmCostInst(unsigned Opcode, unsigned Idx,
57885788
assert(Ty->isIntegerTy());
57895789

57905790
unsigned BitSize = Ty->getPrimitiveSizeInBits();
5791+
unsigned ImmBitWidth = Imm.getBitWidth();
5792+
57915793
// There is no cost model for constants with a bit size of 0. Return TCC_Free
57925794
// here, so that constant hoisting will ignore this constant.
57935795
if (BitSize == 0)
@@ -5813,7 +5815,7 @@ InstructionCost X86TTIImpl::getIntImmCostInst(unsigned Opcode, unsigned Idx,
58135815
// 32-bits. The backend can optimize these cases using a right shift by 32.
58145816
// Ideally we would check the compare predicate here. There also other
58155817
// similar immediates the backend can use shifts for.
5816-
if (Idx == 1 && Imm.getBitWidth() == 64) {
5818+
if (Idx == 1 && ImmBitWidth == 64) {
58175819
uint64_t ImmVal = Imm.getZExtValue();
58185820
if (ImmVal == 0x100000000ULL || ImmVal == 0xffffffff)
58195821
return TTI::TCC_Free;
@@ -5824,14 +5826,14 @@ InstructionCost X86TTIImpl::getIntImmCostInst(unsigned Opcode, unsigned Idx,
58245826
// We support 64-bit ANDs with immediates with 32-bits of leading zeroes
58255827
// by using a 32-bit operation with implicit zero extension. Detect such
58265828
// immediates here as the normal path expects bit 31 to be sign extended.
5827-
if (Idx == 1 && Imm.getBitWidth() == 64 && Imm.isIntN(32))
5829+
if (Idx == 1 && ImmBitWidth == 64 && Imm.isIntN(32))
58285830
return TTI::TCC_Free;
58295831
ImmIdx = 1;
58305832
break;
58315833
case Instruction::Add:
58325834
case Instruction::Sub:
58335835
// For add/sub, we can use the opposite instruction for INT32_MIN.
5834-
if (Idx == 1 && Imm.getBitWidth() == 64 && Imm.getZExtValue() == 0x80000000)
5836+
if (Idx == 1 && ImmBitWidth == 64 && Imm.getZExtValue() == 0x80000000)
58355837
return TTI::TCC_Free;
58365838
ImmIdx = 1;
58375839
break;

0 commit comments

Comments
 (0)