diff options
author | Arnold Schwaighofer <aschwaighofer@apple.com> | 2014-03-28 17:21:32 +0000 |
---|---|---|
committer | Arnold Schwaighofer <aschwaighofer@apple.com> | 2014-03-28 17:21:32 +0000 |
commit | c9d58e8d32731990a7a49c0761b661e511b7c640 (patch) | |
tree | 555f310c4f85e44c1ea6c737a012bdebf26d1f14 /llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp | |
parent | b0d3bcdd328ad8da31058bd8a945fc92e88b9f41 (diff) | |
download | bcm5719-llvm-c9d58e8d32731990a7a49c0761b661e511b7c640.tar.gz bcm5719-llvm-c9d58e8d32731990a7a49c0761b661e511b7c640.zip |
SLPVectorizer: Take credit for free extractelement instructions
Extract element instructions that will be removed when vectorzing lower the
cost.
Patch by Arch D. Robison!
llvm-svn: 205020
Diffstat (limited to 'llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp')
-rw-r--r-- | llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp index 6d1c2c0ffee..d2d4db33f69 100644 --- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp +++ b/llvm/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: |