diff options
author | Evan Cheng <evan.cheng@apple.com> | 2012-05-16 01:54:27 +0000 |
---|---|---|
committer | Evan Cheng <evan.cheng@apple.com> | 2012-05-16 01:54:27 +0000 |
commit | 6100366c2f543ea1bc26b3c22b7543237bd79274 (patch) | |
tree | cfe953004dc513c4a18ec35a1b55580a16b192d0 /lib/Target/X86/X86ISelDAGToDAG.cpp | |
parent | 99534f3a0d503a09f4088b4b3dec2b6200132541 (diff) | |
download | external_llvm-6100366c2f543ea1bc26b3c22b7543237bd79274.zip external_llvm-6100366c2f543ea1bc26b3c22b7543237bd79274.tar.gz external_llvm-6100366c2f543ea1bc26b3c22b7543237bd79274.tar.bz2 |
Avoid creating a cycle when folding load / op with flag / store. PR11451474. rdar://11451474
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@156896 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/X86/X86ISelDAGToDAG.cpp')
-rw-r--r-- | lib/Target/X86/X86ISelDAGToDAG.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/Target/X86/X86ISelDAGToDAG.cpp b/lib/Target/X86/X86ISelDAGToDAG.cpp index 8e2b1d6..0c7b116 100644 --- a/lib/Target/X86/X86ISelDAGToDAG.cpp +++ b/lib/Target/X86/X86ISelDAGToDAG.cpp @@ -1905,6 +1905,20 @@ static bool isLoadIncOrDecStore(StoreSDNode *StoreNode, unsigned Opc, ChainCheck = true; continue; } + + // Make sure using Op as part of the chain would not cause a cycle here. + // In theory, we could check whether the chain node is a predecessor of + // the load. But that can be very expensive. Instead visit the uses and + // make sure they all have smaller node id than the load. + int LoadId = LoadNode->getNodeId(); + for (SDNode::use_iterator UI = Op.getNode()->use_begin(), + UE = UI->use_end(); UI != UE; ++UI) { + if (UI.getUse().getResNo() != 0) + continue; + if (UI->getNodeId() > LoadId) + return false; + } + ChainOps.push_back(Op); } |