Index: lib/CodeGen/SelectionDAG/DAGCombiner.cpp =================================================================== --- lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -10002,8 +10002,11 @@ if (ISD::isNON_TRUNCStore(Chain.getNode())) { StoreSDNode *PrevST = cast(Chain); if (PrevST->getBasePtr() == Ptr && - PrevST->getValue().getValueType() == N->getValueType(0)) - return CombineTo(N, Chain.getOperand(1), Chain); + PrevST->getValue().getValueType() == N->getValueType(0)) { + if (OptLevel != CodeGenOpt::None || + !isa(Chain.getOperand(1))) + return CombineTo(N, Chain.getOperand(1), Chain); + } } }