summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/TargetTransformImpl.cpp
diff options
context:
space:
mode:
authorNadav Rotem <nrotem@apple.com>2012-11-11 05:34:45 +0000
committerNadav Rotem <nrotem@apple.com>2012-11-11 05:34:45 +0000
commit3b99dc62a75c88178ad2a96e96f3f1efb992e59f (patch)
treed548da10e33289b7dd6e2071b6320cf6ac3b7fc8 /llvm/lib/Target/TargetTransformImpl.cpp
parent12930749ab7eddf827bfdb702545052d832ad525 (diff)
downloadbcm5719-llvm-3b99dc62a75c88178ad2a96e96f3f1efb992e59f.tar.gz
bcm5719-llvm-3b99dc62a75c88178ad2a96e96f3f1efb992e59f.zip
Use the isTruncFree and isZExtFree API to figure out of these operations are free. Thanks Andy!
llvm-svn: 167685
Diffstat (limited to 'llvm/lib/Target/TargetTransformImpl.cpp')
-rw-r--r--llvm/lib/Target/TargetTransformImpl.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/llvm/lib/Target/TargetTransformImpl.cpp b/llvm/lib/Target/TargetTransformImpl.cpp
index c07332de329..b36e6f858f7 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.
OpenPOWER on IntegriCloud