Index: lib/CodeGen/SelectionDAG/DAGCombiner.cpp =================================================================== --- lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -14667,6 +14667,10 @@ if (Index->isVolatile() || Index->isIndexed()) break; + // Skip stores with pre/post-inc. + if (St->getNumValues() > 1) + break; + // Find the base pointer and offset for this memory node. BaseIndexOffset Ptr = BaseIndexOffset::match(Index->getBasePtr()); @@ -14681,6 +14685,11 @@ SDNode *NextInChain = Index->getChain().getNode(); while (true) { if (StoreSDNode *STn = dyn_cast(NextInChain)) { + // Skip stores with pre/post-inc. + if (STn->getNumValues() > 1) { + Index = nullptr; + break; + } // We found a store node. Use it for the next iteration. ChainedStores.push_back(STn); Index = STn;