diff options
author | Karthik Bhat <kv.bhat@samsung.com> | 2014-06-06 06:20:08 +0000 |
---|---|---|
committer | Karthik Bhat <kv.bhat@samsung.com> | 2014-06-06 06:20:08 +0000 |
commit | bf56d44cab281a7cec42c6c01caac8e7e7b3ea5c (patch) | |
tree | 15c9a47ff90243fadf3f58d051e92f36c2fd0ef6 /llvm/lib | |
parent | 5627ee47f4ff8efceb6297f7542fd05e4bb0c2ba (diff) | |
download | bcm5719-llvm-bf56d44cab281a7cec42c6c01caac8e7e7b3ea5c.tar.gz bcm5719-llvm-bf56d44cab281a7cec42c6c01caac8e7e7b3ea5c.zip |
Fix PR19657 (scalar loads not combined into vector load)
If we have common uses on separate paths in the tree; process the one with greater common depth first.
This makes sure that we do not assume we need to extract a load when it is actually going to be part of a vectorized tree.
Review: http://reviews.llvm.org/D3800
llvm-svn: 210310
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp index ce0a009e1cb..d8621670959 100644 --- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp +++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp @@ -914,8 +914,20 @@ void BoUpSLP::buildTree_rec(ArrayRef<Value *> VL, unsigned Depth) { if (isa<BinaryOperator>(VL0) && VL0->isCommutative()) { ValueList Left, Right; reorderInputsAccordingToOpcode(VL, Left, Right); - buildTree_rec(Left, Depth + 1); - buildTree_rec(Right, Depth + 1); + BasicBlock *LeftBB = getSameBlock(Left); + BasicBlock *RightBB = getSameBlock(Right); + // If we have common uses on separate paths in the tree make sure we + // process the one with greater common depth first. + // We can use block numbering to determine the subtree traversal as + // earler user has to come in between the common use and the later user. + if (LeftBB && RightBB && LeftBB == RightBB && + getLastIndex(Right) > getLastIndex(Left)) { + buildTree_rec(Right, Depth + 1); + buildTree_rec(Left, Depth + 1); + } else { + buildTree_rec(Left, Depth + 1); + buildTree_rec(Right, Depth + 1); + } return; } |