summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorNadav Rotem <nrotem@apple.com>2012-11-02 21:47:47 +0000
committerNadav Rotem <nrotem@apple.com>2012-11-02 21:47:47 +0000
commit2b0c96f71ff1f26617dd805cafa35bf9a29c5a60 (patch)
treeae8242f8404bf1d1a7e34b4543d1361c570d4270 /lib
parentfb60a4e823b46f459cd6d7951b98cbeb3b29f310 (diff)
downloadllvm-2b0c96f71ff1f26617dd805cafa35bf9a29c5a60.tar.gz
llvm-2b0c96f71ff1f26617dd805cafa35bf9a29c5a60.tar.bz2
llvm-2b0c96f71ff1f26617dd805cafa35bf9a29c5a60.tar.xz
Scalar Bitcasts and Truncs are usually free
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167323 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Target/TargetTransformImpl.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/Target/TargetTransformImpl.cpp b/lib/Target/TargetTransformImpl.cpp
index dbbf37a7dd..4cd07cd6c3 100644
--- a/lib/Target/TargetTransformImpl.cpp
+++ b/lib/Target/TargetTransformImpl.cpp
@@ -213,6 +213,11 @@ 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)
+ return 0;
+
// Just check the op cost. If the operation is legal then assume it costs 1.
if (!TLI->isOperationExpand(ISD, DstLT.second))
return 1;