Index: llvm/include/llvm/CodeGen/BasicTTIImpl.h =================================================================== --- llvm/include/llvm/CodeGen/BasicTTIImpl.h +++ llvm/include/llvm/CodeGen/BasicTTIImpl.h @@ -694,8 +694,8 @@ std::pair SrcLT = TLI->getTypeLegalizationCost(DL, Src); std::pair DstLT = TLI->getTypeLegalizationCost(DL, Dst); - unsigned SrcSize = SrcLT.second.getSizeInBits(); - unsigned DstSize = DstLT.second.getSizeInBits(); + TypeSize SrcSize = SrcLT.second.getSizeInBits(); + TypeSize DstSize = DstLT.second.getSizeInBits(); bool IntOrPtrSrc = Src->isIntegerTy() || Src->isPointerTy(); bool IntOrPtrDst = Dst->isIntegerTy() || Dst->isPointerTy(); @@ -769,8 +769,7 @@ // Check vector-to-vector casts. if (DstVTy && SrcVTy) { // If the cast is between same-sized registers, then the check is simple. - if (SrcLT.first == DstLT.first && - SrcLT.second.getSizeInBits() == DstLT.second.getSizeInBits()) { + if (SrcLT.first == DstLT.first && SrcSize == DstSize) { // Assume that Zext is done using AND. if (Opcode == Instruction::ZExt) Index: llvm/test/Analysis/CostModel/AArch64/sve-bitcast.ll =================================================================== --- /dev/null +++ llvm/test/Analysis/CostModel/AArch64/sve-bitcast.ll @@ -0,0 +1,11 @@ +; RUN: opt -mtriple=aarch64-linux-gnu -mattr=+sve -cost-model -analyze < %s 2>%t | FileCheck %s +; RUN: FileCheck --check-prefix=WARN --allow-empty %s <%t + +; WARN-NOT: warning + +; CHECK: Found an estimated cost of 0 for instruction: %b = bitcast %a to + +define @foo( %a, i32 %x) { + %b = bitcast %a to + ret %b +}