@@ -5788,6 +5788,8 @@ InstructionCost X86TTIImpl::getIntImmCostInst(unsigned Opcode, unsigned Idx,
5788
5788
assert (Ty->isIntegerTy ());
5789
5789
5790
5790
unsigned BitSize = Ty->getPrimitiveSizeInBits ();
5791
+ unsigned ImmBitWidth = Imm.getBitWidth ();
5792
+
5791
5793
// There is no cost model for constants with a bit size of 0. Return TCC_Free
5792
5794
// here, so that constant hoisting will ignore this constant.
5793
5795
if (BitSize == 0 )
@@ -5813,7 +5815,7 @@ InstructionCost X86TTIImpl::getIntImmCostInst(unsigned Opcode, unsigned Idx,
5813
5815
// 32-bits. The backend can optimize these cases using a right shift by 32.
5814
5816
// Ideally we would check the compare predicate here. There also other
5815
5817
// similar immediates the backend can use shifts for.
5816
- if (Idx == 1 && Imm. getBitWidth () == 64 ) {
5818
+ if (Idx == 1 && ImmBitWidth == 64 ) {
5817
5819
uint64_t ImmVal = Imm.getZExtValue ();
5818
5820
if (ImmVal == 0x100000000ULL || ImmVal == 0xffffffff )
5819
5821
return TTI::TCC_Free;
@@ -5824,14 +5826,14 @@ InstructionCost X86TTIImpl::getIntImmCostInst(unsigned Opcode, unsigned Idx,
5824
5826
// We support 64-bit ANDs with immediates with 32-bits of leading zeroes
5825
5827
// by using a 32-bit operation with implicit zero extension. Detect such
5826
5828
// 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 ))
5828
5830
return TTI::TCC_Free;
5829
5831
ImmIdx = 1 ;
5830
5832
break ;
5831
5833
case Instruction::Add:
5832
5834
case Instruction::Sub:
5833
5835
// 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 )
5835
5837
return TTI::TCC_Free;
5836
5838
ImmIdx = 1 ;
5837
5839
break ;
0 commit comments