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 | 58a95f0c8afa5229c350ca5944c499b3e47dc8c8 (patch) | |
| tree | bff4b8c37f8081f379f6e204e40f03e90d526b67 /llvm/lib/Target | |
| parent | cb4ca11bef85fb1815a289e3c5a8ed44b4fc4c1b (diff) | |
| download | bcm5719-llvm-58a95f0c8afa5229c350ca5944c499b3e47dc8c8.tar.gz bcm5719-llvm-58a95f0c8afa5229c350ca5944c499b3e47dc8c8.zip | |
Avoid creating a cycle when folding load / op with flag / store. PR11451474. rdar://11451474
llvm-svn: 156896
Diffstat (limited to 'llvm/lib/Target')
| -rw-r--r-- | llvm/lib/Target/X86/X86ISelDAGToDAG.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp b/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp index 8e2b1d6b5dd..0c7b11625b7 100644 --- a/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp +++ b/llvm/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); } |

