summaryrefslogtreecommitdiff
path: root/lib/Transforms
diff options
context:
space:
mode:
authorArnold Schwaighofer <aschwaighofer@apple.com>2014-03-28 17:21:32 +0000
committerArnold Schwaighofer <aschwaighofer@apple.com>2014-03-28 17:21:32 +0000
commitce3623782657d77cefbd03ab0d545a0805e9c5e9 (patch)
tree0b58669f05abafdadeee4b15da83e55acf1b2d04 /lib/Transforms
parentaa0a2a35f830e3bc2078c0054349a102b4444ea4 (diff)
downloadllvm-ce3623782657d77cefbd03ab0d545a0805e9c5e9.tar.gz
llvm-ce3623782657d77cefbd03ab0d545a0805e9c5e9.tar.bz2
llvm-ce3623782657d77cefbd03ab0d545a0805e9c5e9.tar.xz
SLPVectorizer: Take credit for free extractelement instructions
Extract element instructions that will be removed when vectorzing lower the cost. Patch by Arch D. Robison! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@205020 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r--lib/Transforms/Vectorize/SLPVectorizer.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/Transforms/Vectorize/SLPVectorizer.cpp b/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 6d1c2c0ffe..d2d4db33f6 100644
--- a/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -1015,8 +1015,17 @@ int BoUpSLP::getEntryCost(TreeEntry *E) {
return 0;
}
case Instruction::ExtractElement: {
- if (CanReuseExtract(VL))
- return 0;
+ if (CanReuseExtract(VL)) {
+ int DeadCost = 0;
+ for (unsigned i = 0, e = VL.size(); i < e; ++i) {
+ ExtractElementInst *E = cast<ExtractElementInst>(VL[i]);
+ if (E->hasOneUse())
+ // Take credit for instruction that will become dead.
+ DeadCost +=
+ TTI->getVectorInstrCost(Instruction::ExtractElement, VecTy, i);
+ }
+ return -DeadCost;
+ }
return getGatherCost(VecTy);
}
case Instruction::ZExt: