@@ -81,23 +81,25 @@ SDValue RISCVSelectionDAGInfo::EmitTargetCodeForMemset(
8181
8282 uint64_t NumberOfBytesToWrite = ConstantSize->getZExtValue ();
8383
84- // Do this only if it is word aligned and we write multiple of 4 bytes.
84+ // Do this only if it is word aligned and we write a multiple of 4 bytes.
8585 if (!(Alignment >= 4 ) || !((NumberOfBytesToWrite & 3 ) == 0 ))
8686 return SDValue ();
8787
8888 SmallVector<SDValue, 8 > OutChains;
8989 SDValue SrcValueReplicated = DAG.getNode (ISD::ZERO_EXTEND, dl, MVT::i32 , Src);
9090 int NumberOfWords = NumberOfBytesToWrite / 4 ;
9191 MachineFunction &MF = DAG.getMachineFunction ();
92+ auto Volatile =
93+ isVolatile ? MachineMemOperand::MOVolatile : MachineMemOperand::MONone;
9294
9395 // Helper for constructing the QC_SETWMI instruction
9496 auto getSetwmiNode = [&](uint8_t SizeWords, uint8_t OffsetSetwmi) -> SDValue {
9597 SDValue Ops[] = {Chain, SrcValueReplicated, Dst,
9698 DAG.getTargetConstant (SizeWords, dl, MVT::i32 ),
9799 DAG.getTargetConstant (OffsetSetwmi, dl, MVT::i32 )};
98100 MachineMemOperand *BaseMemOperand = MF.getMachineMemOperand (
99- DstPtrInfo.getWithOffset (OffsetSetwmi), MachineMemOperand::MOStore,
100- SizeWords * 4 , Align (4 ));
101+ DstPtrInfo.getWithOffset (OffsetSetwmi),
102+ MachineMemOperand::MOStore | Volatile, SizeWords * 4 , Align (4 ));
101103 return DAG.getMemIntrinsicNode (RISCVISD::QC_SETWMI, dl,
102104 DAG.getVTList (MVT::Other), Ops, MVT::i32 ,
103105 BaseMemOperand);
@@ -122,7 +124,7 @@ SDValue RISCVSelectionDAGInfo::EmitTargetCodeForMemset(
122124 // QC_SETWMI reg1, N, 64(reg2)
123125 //
124126 // For 33-48 words, we would like to use (16, 16, n), but that means the last
125- // QC_SETWMI needs an offset of 128 which the instruction doesnt support.
127+ // QC_SETWMI needs an offset of 128 which the instruction doesn't support.
126128 // So in this case we use a length of 15 for the second instruction and we do
127129 // the rest with the third instruction.
128130 // This means the maximum inlined number of words is 47 (for now):
0 commit comments