summaryrefslogtreecommitdiff
path: root/lib/Target
diff options
context:
space:
mode:
authorManman Ren <mren@apple.com>2012-08-31 23:16:57 +0000
committerManman Ren <mren@apple.com>2012-08-31 23:16:57 +0000
commit2b7a2e8833c00a484bd9d54db77959cfe31dfc8d (patch)
tree7f7412d47758ef24bfbd4280d7ce04574c6a942e /lib/Target
parentdfb1e4babd2e825d951d42bcb45438b48c45b155 (diff)
downloadllvm-2b7a2e8833c00a484bd9d54db77959cfe31dfc8d.tar.gz
llvm-2b7a2e8833c00a484bd9d54db77959cfe31dfc8d.tar.bz2
llvm-2b7a2e8833c00a484bd9d54db77959cfe31dfc8d.tar.xz
SelectionDAG: when constructing VZEXT_LOAD from other loads, make sure its
output chain is correctly setup. As an example, if the original load must happen before later stores, we need to make sure the constructed VZEXT_LOAD is constrained to be before the stores. rdar://11457792 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@163036 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target')
-rw-r--r--lib/Target/X86/X86ISelLowering.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/Target/X86/X86ISelLowering.cpp b/lib/Target/X86/X86ISelLowering.cpp
index f4329d3bf9..2d84860610 100644
--- a/lib/Target/X86/X86ISelLowering.cpp
+++ b/lib/Target/X86/X86ISelLowering.cpp
@@ -4977,6 +4977,18 @@ static SDValue EltsFromConsecutiveLoads(EVT VT, SmallVectorImpl<SDValue> &Elts,
LDBase->getAlignment(),
false/*isVolatile*/, true/*ReadMem*/,
false/*WriteMem*/);
+
+ // Make sure the newly-created LOAD is in the same position as LDBase in
+ // terms of dependency. We create a TokenFactor for LDBase and ResNode, and
+ // update uses of LDBase's output chain to use the TokenFactor.
+ if (LDBase->hasAnyUseOfValue(1)) {
+ SDValue NewChain = DAG.getNode(ISD::TokenFactor, DL, MVT::Other,
+ SDValue(LDBase, 1), SDValue(ResNode.getNode(), 1));
+ DAG.ReplaceAllUsesOfValueWith(SDValue(LDBase, 1), NewChain);
+ DAG.UpdateNodeOperands(NewChain.getNode(), SDValue(LDBase, 1),
+ SDValue(ResNode.getNode(), 1));
+ }
+
return DAG.getNode(ISD::BITCAST, DL, VT, ResNode);
}
return SDValue();