aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/BasicTargetTransformInfo.cpp
diff options
context:
space:
mode:
authorHal Finkel <hfinkel@anl.gov>2014-04-02 23:18:54 +0000
committerHal Finkel <hfinkel@anl.gov>2014-04-02 23:18:54 +0000
commit55312debee5c3f224cd36913d4a00a6ce91676c5 (patch)
tree21c18048555b3c8b1e51f777ef886a5bd9af71f1 /llvm/lib/CodeGen/BasicTargetTransformInfo.cpp
parent519a45ce36189771f8665fa6a19be09b7afdbe37 (diff)
downloadllvm-55312debee5c3f224cd36913d4a00a6ce91676c5.zip
llvm-55312debee5c3f224cd36913d4a00a6ce91676c5.tar.gz
llvm-55312debee5c3f224cd36913d4a00a6ce91676c5.tar.bz2
Fix multi-register costs in BasicTTI::getCastInstrCost
For an cast (extension, etc.), the currently logic predicts a low cost if the associated operation (keyed on the destination type) is legal (or promoted). This is not true when the number of values required to legalize the type is changing. For example, <8 x i16> being sign extended by <8 x i32> is not generically cheap on PPC with VSX, even though sign extension to v4i32 is legal, because two output v4i32 values are required compared to the single v8i16 input value, and without custom logic in the target, this conversion will scalarize. llvm-svn: 205487
Diffstat (limited to 'llvm/lib/CodeGen/BasicTargetTransformInfo.cpp')
-rw-r--r--llvm/lib/CodeGen/BasicTargetTransformInfo.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/BasicTargetTransformInfo.cpp b/llvm/lib/CodeGen/BasicTargetTransformInfo.cpp
index 03c5eba..25486cf 100644
--- a/llvm/lib/CodeGen/BasicTargetTransformInfo.cpp
+++ b/llvm/lib/CodeGen/BasicTargetTransformInfo.cpp
@@ -297,7 +297,8 @@ unsigned BasicTTI::getCastInstrCost(unsigned Opcode, Type *Dst,
return 0;
// If the cast is marked as legal (or promote) then assume low cost.
- if (TLI->isOperationLegalOrPromote(ISD, DstLT.second))
+ if (SrcLT.first == DstLT.first &&
+ TLI->isOperationLegalOrPromote(ISD, DstLT.second))
return 1;
// Handle scalar conversions.