When clamping the index for a memory access to a stacked vector we must
take into account the entire type being accessed, not just assume that
we are accessing only a single element.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp | ||
---|---|---|
7797 | Question: Shouldn't this remain <? My thinking: Logically, the thing on the left is the maximum index, and when you increment that thing, it needs to remain less than NElts to still be a valid index. | |
7820 | Did you entertain constructing a 1-element vector here and getting rid of the special case? |
llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp | ||
---|---|---|
7797 | Not quite, if NumSubElts is 1, then the index is IdxCst->getZExtValue(), not IdxCst->getZExtValue() + 1. Perhaps it's better to think of this like the following: IdxCst->getZExtValue() + (NumSubElts - 1) < NElts |
- Rearrange if statement to clarify intent
- Construct 1-element vector in getVectorElementPointer to avoid special cases
llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp | ||
---|---|---|
7797 | This looks better, thanks for clarifying. Perhaps the comment on the if statement could be updated to account for the fact an n-element subvec is involved. |
Question: Shouldn't this remain <? My thinking: Logically, the thing on the left is the maximum index, and when you increment that thing, it needs to remain less than NElts to still be a valid index.