Skip to content

Commit 115f768

Browse files
authored
[RISCV] Correct alignment of one-active (de)interleave cases (#150052)
Noticed this while going to rewrite the load case as a DAG combine. I don't have a test case which demonstrates this leading to a miscompile, but it seems like it could be possible.
1 parent 75ec725 commit 115f768

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

llvm/lib/Target/RISCV/RISCVInterleavedAccess.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ bool RISCVTargetLowering::lowerInterleavedLoad(
232232
Builder.CreateIntrinsic(Intrinsic::experimental_vp_strided_load,
233233
{VTy, BasePtr->getType(), Stride->getType()},
234234
{BasePtr, Stride, Mask, VL});
235+
Alignment = commonAlignment(Alignment, Indices[0] * ScalarSizeInBytes);
235236
CI->addParamAttr(0,
236237
Attribute::getWithAlignment(CI->getContext(), Alignment));
237238
Shuffles[0]->replaceAllUsesWith(CI);
@@ -303,8 +304,9 @@ bool RISCVTargetLowering::lowerInterleavedStore(StoreInst *SI,
303304
Intrinsic::experimental_vp_strided_store,
304305
{Data->getType(), BasePtr->getType(), Stride->getType()},
305306
{Data, BasePtr, Stride, Mask, VL});
307+
Align Alignment = commonAlignment(SI->getAlign(), Index * ScalarSizeInBytes);
306308
CI->addParamAttr(
307-
1, Attribute::getWithAlignment(CI->getContext(), SI->getAlign()));
309+
1, Attribute::getWithAlignment(CI->getContext(), Alignment));
308310

309311
return true;
310312
}

0 commit comments

Comments
 (0)