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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210310 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Karthik Bhat
2014-06-06 06:20:08 +00:00
parent dc4c7fb098
commit b73a9b384e
2 changed files with 87 additions and 2 deletions

View File

@ -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;
}