diff options
author | Nadav Rotem <nrotem@apple.com> | 2012-11-11 05:34:45 +0000 |
---|---|---|
committer | Nadav Rotem <nrotem@apple.com> | 2012-11-11 05:34:45 +0000 |
commit | 955cf5326680bda17d6b8aa2dc9168927af8547f (patch) | |
tree | a8bd57b6b319cb7516d7d94ece90aef1d94cbeed /lib/Target/TargetTransformImpl.cpp | |
parent | 9005b8d27d68caeb893d74aa75cd679972d86cef (diff) |
Use the isTruncFree and isZExtFree API to figure out of these operations are free. Thanks Andy!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167685 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/TargetTransformImpl.cpp')
-rw-r--r-- | lib/Target/TargetTransformImpl.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/Target/TargetTransformImpl.cpp b/lib/Target/TargetTransformImpl.cpp index c07332de32..b36e6f858f 100644 --- a/lib/Target/TargetTransformImpl.cpp +++ b/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. |