Skip to content

Commit 26b786a

Browse files
authored
[NVPTX] Restrict combining to properly aligned v16i8 vectors. (#107919)
Fixes generation of invalid loads leading to misaligned access errors. The bug got exposed by SLP vectorizer change ec360d6 which allowed SLP to produce `v16i8` vectors. Also updated the tests to use automatic check generator.
1 parent f12e10b commit 26b786a

File tree

2 files changed

+452
-10
lines changed

2 files changed

+452
-10
lines changed

llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6038,7 +6038,11 @@ static SDValue PerformLOADCombine(SDNode *N,
60386038
// elements can be optimised away instead of being needlessly split during
60396039
// legalization, which involves storing to the stack and loading it back.
60406040
EVT VT = N->getValueType(0);
6041-
if (VT != MVT::v16i8)
6041+
bool CorrectlyAligned =
6042+
DCI.DAG.getTargetLoweringInfo().allowsMemoryAccessForAlignment(
6043+
*DAG.getContext(), DAG.getDataLayout(), LD->getMemoryVT(),
6044+
*LD->getMemOperand());
6045+
if (!(VT == MVT::v16i8 && CorrectlyAligned))
60426046
return SDValue();
60436047

60446048
SDLoc DL(N);

0 commit comments

Comments
 (0)