summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/TargetTransformImpl.cpp
diff options
context:
space:
mode:
authorNadav Rotem <nrotem@apple.com>2012-11-05 22:20:53 +0000
committerNadav Rotem <nrotem@apple.com>2012-11-05 22:20:53 +0000
commitae79765676f5fda98cff4131be5abefc77c0317d (patch)
tree6bcc576588fc964e86f832243b4df4c9a26c367f /llvm/lib/Target/TargetTransformImpl.cpp
parent52be619c84d51713ccf7271c2be5dfefd04ee23a (diff)
downloadbcm5719-llvm-ae79765676f5fda98cff4131be5abefc77c0317d.tar.gz
bcm5719-llvm-ae79765676f5fda98cff4131be5abefc77c0317d.zip
Code Model: Improve the accuracy of the zext/sext/trunc vector cost estimation.
llvm-svn: 167412
Diffstat (limited to 'llvm/lib/Target/TargetTransformImpl.cpp')
-rw-r--r--llvm/lib/Target/TargetTransformImpl.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/llvm/lib/Target/TargetTransformImpl.cpp b/llvm/lib/Target/TargetTransformImpl.cpp
index 4b427a2b6d4..ca0dd9a54ed 100644
--- a/llvm/lib/Target/TargetTransformImpl.cpp
+++ b/llvm/lib/Target/TargetTransformImpl.cpp
@@ -101,7 +101,7 @@ int VectorTargetTransformImpl::InstructionOpcodeToISD(unsigned Opcode) const {
case AtomicRMW: return 0;
case Trunc: return ISD::TRUNCATE;
case ZExt: return ISD::ZERO_EXTEND;
- case SExt: return ISD::SEXTLOAD;
+ case SExt: return ISD::SIGN_EXTEND;
case FPToUI: return ISD::FP_TO_UINT;
case FPToSI: return ISD::FP_TO_SINT;
case UIToFP: return ISD::UINT_TO_FP;
@@ -235,9 +235,17 @@ unsigned VectorTargetTransformImpl::getCastInstrCost(unsigned Opcode, Type *Dst,
SrcLT.second.getSizeInBits() == DstLT.second.getSizeInBits()) {
// Bitcast between types that are legalized to the same type are free.
- if (Opcode == Instruction::BitCast)
+ if (Opcode == Instruction::BitCast || Opcode == Instruction::Trunc)
return 0;
+ // Assume that Zext is done using AND.
+ if (Opcode == Instruction::ZExt)
+ return 1;
+
+ // Assume that sext is done using SHL and SRA.
+ if (Opcode == Instruction::SExt)
+ return 2;
+
// Just check the op cost. If the operation is legal then assume it costs
// 1 and multiply by the type-legalization overhead.
if (!TLI->isOperationExpand(ISD, DstLT.second))
@@ -310,7 +318,6 @@ unsigned VectorTargetTransformImpl::getCmpSelInstrCost(unsigned Opcode,
return 1;
}
-/// Returns the expected cost of Vector Insert and Extract.
unsigned VectorTargetTransformImpl::getVectorInstrCost(unsigned Opcode,
Type *Val,
unsigned Index) const {
OpenPOWER on IntegriCloud