diff --git a/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h b/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h --- a/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h +++ b/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h @@ -986,8 +986,6 @@ } Type *Ty = U->getType(); - Type *OpTy = - U->getNumOperands() == 1 ? U->getOperand(0)->getType() : nullptr; unsigned Opcode = Operator::getOpcode(U); auto *I = dyn_cast(U); switch (Opcode) { @@ -1059,9 +1057,11 @@ case Instruction::FPExt: case Instruction::SExt: case Instruction::ZExt: - case Instruction::AddrSpaceCast: + case Instruction::AddrSpaceCast: { + Type *OpTy = U->getOperand(0)->getType(); return TargetTTI->getCastInstrCost( Opcode, Ty, OpTy, TTI::getCastContextHint(I), CostKind, I); + } case Instruction::Store: { auto *SI = cast(U); Type *ValTy = U->getOperand(0)->getType();