Index: lib/CodeGen/SelectionDAG/DAGCombiner.cpp =================================================================== --- lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -14012,10 +14012,23 @@ DEBUG(dbgs() << "Load alias\n"); Aliases.push_back(Chain); } else { - // Look further up the chain. + SDValue NextChain = Chain.getOperand(0); + + if (!isa(NextChain)) { + // Don't continue the search if we see a chain dependency that isn't a + // memory access. + // + // e.g. we could have a dependency on a CopyFromReg into the pointer + // value of a load. + Chains.push_back(Chain); + break; + } + + // Look further up the chain at possible memory dependencies. + Chains.push_back(NextChain); DEBUG(dbgs() << "Look up load / store chain: "); - Chain.getOperand(0)->dump(&DAG); - Chains.push_back(Chain.getOperand(0)); + NextChain->dump(&DAG); + Chains.push_back(NextChain); ++Depth; } break;