Index: lib/CodeGen/SelectionDAG/LegalizeDAG.cpp =================================================================== --- lib/CodeGen/SelectionDAG/LegalizeDAG.cpp +++ lib/CodeGen/SelectionDAG/LegalizeDAG.cpp @@ -773,9 +773,16 @@ // Promote to a byte-sized store with upper bits zero if not // storing an integral number of bytes. For example, promote // TRUNCSTORE:i1 X -> TRUNCSTORE:i8 (and X, 1) + + EVT ScalarStVT = StVT.getScalarType(); EVT NVT = EVT::getIntegerVT(*DAG.getContext(), - StVT.getStoreSizeInBits()); - Value = DAG.getZeroExtendInReg(Value, dl, StVT); + ScalarStVT.getStoreSizeInBits()); + if (StVT.isVector()) { + NVT = EVT::getVectorVT(*DAG.getContext(), NVT, + StVT.getVectorNumElements()); + } + + Value = DAG.getZeroExtendInReg(Value, dl, ScalarStVT); SDValue Result = DAG.getTruncStore(Chain, dl, Value, Ptr, ST->getPointerInfo(), NVT, isVolatile, isNonTemporal, Alignment,