From: Nadav Rotem Date: Sun, 11 Nov 2012 05:34:45 +0000 (+0000) Subject: Use the isTruncFree and isZExtFree API to figure out of these operations are free... X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3b99dc62a75c88178ad2a96e96f3f1efb992e59f;p=platform%2Fupstream%2Fllvm.git Use the isTruncFree and isZExtFree API to figure out of these operations are free. Thanks Andy! llvm-svn: 167685 --- diff --git a/llvm/lib/Target/TargetTransformImpl.cpp b/llvm/lib/Target/TargetTransformImpl.cpp index c07332d..b36e6f8 100644 --- a/llvm/lib/Target/TargetTransformImpl.cpp +++ b/llvm/lib/Target/TargetTransformImpl.cpp @@ -214,8 +214,16 @@ unsigned VectorTargetTransformImpl::getCastInstrCost(unsigned Opcode, Type *Dst, // Handle scalar conversions. if (!Src->isVectorTy() && !Dst->isVectorTy()) { - // Scalar bitcasts and truncs are usually free. - if (Opcode == Instruction::BitCast || Opcode == Instruction::Trunc) + // Scalar bitcasts are usually free. + if (Opcode == Instruction::BitCast) + return 0; + + if (Opcode == Instruction::Trunc && + TLI->isTruncateFree(SrcLT.second, DstLT.second)) + return 0; + + if (Opcode == Instruction::ZExt && + TLI->isZExtFree(SrcLT.second, DstLT.second)) return 0; // Just check the op cost. If the operation is legal then assume it costs 1.