Index: llvm/include/llvm/Analysis/TargetTransformInfoImpl.h =================================================================== --- llvm/include/llvm/Analysis/TargetTransformInfoImpl.h +++ llvm/include/llvm/Analysis/TargetTransformInfoImpl.h @@ -875,15 +875,18 @@ return TTI::TCC_Expensive; case Instruction::IntToPtr: case Instruction::PtrToInt: + case Instruction::SIToFP: + case Instruction::UIToFP: + case Instruction::FPToUI: + case Instruction::FPToSI: case Instruction::Trunc: + case Instruction::FPTrunc: case Instruction::BitCast: + case Instruction::AddrSpaceCast: case Instruction::FPExt: case Instruction::SExt: case Instruction::ZExt: - if (TargetTTI->getCastInstrCost(Opcode, Ty, OpTy, CostKind, I) == - TTI::TCC_Free) - return TTI::TCC_Free; - break; + return TargetTTI->getCastInstrCost(Opcode, Ty, OpTy, CostKind, I); } // By default, just classify everything as 'basic'. return TTI::TCC_Basic; Index: llvm/lib/Analysis/TargetTransformInfo.cpp =================================================================== --- llvm/lib/Analysis/TargetTransformInfo.cpp +++ llvm/lib/Analysis/TargetTransformInfo.cpp @@ -1258,10 +1258,8 @@ case Instruction::Trunc: case Instruction::FPTrunc: case Instruction::BitCast: - case Instruction::AddrSpaceCast: { - Type *SrcTy = I->getOperand(0)->getType(); - return getCastInstrCost(I->getOpcode(), I->getType(), SrcTy, CostKind, I); - } + case Instruction::AddrSpaceCast: + return getUserCost(I, CostKind); case Instruction::ExtractElement: { const ExtractElementInst *EEI = cast(I); ConstantInt *CI = dyn_cast(I->getOperand(1)); Index: llvm/lib/Target/PowerPC/PPCTargetTransformInfo.cpp =================================================================== --- llvm/lib/Target/PowerPC/PPCTargetTransformInfo.cpp +++ llvm/lib/Target/PowerPC/PPCTargetTransformInfo.cpp @@ -212,7 +212,8 @@ unsigned PPCTTIImpl::getUserCost(const User *U, ArrayRef Operands, TTI::TargetCostKind CostKind) { - if (U->getType()->isVectorTy()) { + // We already implement getCastInstrCost and perform the vector adjustment there. + if (!isa(U) && U->getType()->isVectorTy()) { // Instructions that need to be split should cost more. std::pair LT = TLI->getTypeLegalizationCost(DL, U->getType()); return LT.first * BaseT::getUserCost(U, Operands, CostKind); Index: llvm/lib/Target/SystemZ/SystemZTargetTransformInfo.cpp =================================================================== --- llvm/lib/Target/SystemZ/SystemZTargetTransformInfo.cpp +++ llvm/lib/Target/SystemZ/SystemZTargetTransformInfo.cpp @@ -692,6 +692,12 @@ int SystemZTTIImpl::getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src, TTI::TargetCostKind CostKind, const Instruction *I) { + // FIXME: Can the logic below also be used for these cost kinds? + if (CostKind == TTI::TCK_CodeSize || CostKind == TTI::TCK_SizeAndLatency) { + int BaseCost = BaseT::getCastInstrCost(Opcode, Dst, Src, CostKind, I); + return BaseCost == 0 ? BaseCost : 1; + } + unsigned DstScalarBits = Dst->getScalarSizeInBits(); unsigned SrcScalarBits = Src->getScalarSizeInBits(); Index: llvm/test/CodeGen/ARM/fragmented-args-multiple-regs.ll =================================================================== --- llvm/test/CodeGen/ARM/fragmented-args-multiple-regs.ll +++ llvm/test/CodeGen/ARM/fragmented-args-multiple-regs.ll @@ -25,7 +25,6 @@ ; CHECK: DBG_VALUE [[REG1:%[0-9]+]], $noreg, !14, !DIExpression(DW_OP_LLVM_fragment, 32, 32 ; CHECK: DBG_VALUE [[REG2:%[0-9]+]], $noreg, !14, !DIExpression(DW_OP_LLVM_fragment, 0, 32 ; CHECK: DBG_VALUE [[REG2]], $noreg, !15, !DIExpression({{.+}}DW_OP_LLVM_fragment, 0, 32 -; CHECK: DBG_VALUE $noreg, $noreg, !15, !DIExpression({{.+}}DW_OP_LLVM_fragment, 32, 32 declare void @llvm.dbg.value(metadata, metadata, metadata)