summaryrefslogtreecommitdiff
path: root/lib/Target/PowerPC/PPCTargetTransformInfo.cpp
diff options
context:
space:
mode:
authorBill Schmidt <wschmidt@linux.vnet.ibm.com>2013-02-07 20:33:57 +0000
committerBill Schmidt <wschmidt@linux.vnet.ibm.com>2013-02-07 20:33:57 +0000
commit8f7dc823bfda3efede14a3cf9c294a2da3ad8777 (patch)
treeddaae3b6b4c6acb292464fb12ee9d182d11df94d /lib/Target/PowerPC/PPCTargetTransformInfo.cpp
parent0c66403efdf88ff4f247b6a9f45339bb3a893235 (diff)
downloadllvm-8f7dc823bfda3efede14a3cf9c294a2da3ad8777.tar.gz
llvm-8f7dc823bfda3efede14a3cf9c294a2da3ad8777.tar.bz2
llvm-8f7dc823bfda3efede14a3cf9c294a2da3ad8777.tar.xz
Constrain PowerPC autovectorization to fix bug 15041.
Certain vector operations don't vectorize well with the current PowerPC implementation. Element insert/extract performs poorly without VSX support because Altivec requires going through memory. SREM, UREM, and VSELECT all produce bad scalar code. There's a lot of work to do for the cost model before autovectorization will be tuned well, and this is not an attempt to address the larger problem. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174660 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/PowerPC/PPCTargetTransformInfo.cpp')
-rw-r--r--lib/Target/PowerPC/PPCTargetTransformInfo.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/Target/PowerPC/PPCTargetTransformInfo.cpp b/lib/Target/PowerPC/PPCTargetTransformInfo.cpp
index 88b63e65d1..f57d7643e1 100644
--- a/lib/Target/PowerPC/PPCTargetTransformInfo.cpp
+++ b/lib/Target/PowerPC/PPCTargetTransformInfo.cpp
@@ -194,6 +194,25 @@ unsigned PPCTTI::getVectorInstrCost(unsigned Opcode, Type *Val,
unsigned Index) const {
assert(Val->isVectorTy() && "This must be a vector type");
+ const unsigned Awful = 1000;
+
+ // Vector element insert/extract with Altivec is very expensive.
+ // Until VSX is available, avoid vectorizing loops that require
+ // these operations.
+ if (Opcode == ISD::EXTRACT_VECTOR_ELT ||
+ Opcode == ISD::INSERT_VECTOR_ELT)
+ return Awful;
+
+ // We don't vectorize SREM/UREM so well. Constrain the vectorizer
+ // for those as well.
+ if (Opcode == ISD::SREM || Opcode == ISD::UREM)
+ return Awful;
+
+ // VSELECT is not yet implemented, leading to use of insert/extract
+ // and ISEL, hence not a good idea.
+ if (Opcode == ISD::VSELECT)
+ return Awful;
+
return TargetTransformInfo::getVectorInstrCost(Opcode, Val, Index);
}