Repository navigation
Conversation
naye-gg
marked this pull request as ready for review
November 15, 2026 22:06
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes apache/tvm#20779.
Problem
A masked load or store whose index is a
Rampwith a non-unit stride passes the TIRx well-formedness check, but LLVM module verification fails:For non-unit strides,
BufferAccessHelperemits one access per lane, but each lane still receives the full vector predicate (<N x i1>). Passing only the lane'si1is not enough either:llvm.masked.loadandllvm.masked.storeonly accept vector types, so a scalar access is rejected withIntrinsic has incorrect return type!. Unit-stride accesses are not affected, since they are emitted as a single vector access.Fix
src/codegen/llvm/codegen_llvm.cc:BufferAccessHelper: when the index has more than one lane and the predicate has the same number of lanes, extract laneiof the predicate for the per-lane access. Scalable predicates are skipped, becauselanes()is not defined for them.CreateMaskedLoad: when the predicate is a scalar, emit the load as<1 x T>with a<1 x i1>mask and extract element 0. The load instruction is returned, so alias info is still attached to the memory access.CreateMaskedStore: when the predicate is a scalar, store the value as<1 x T>with a<1 x i1>mask.Tests
Added to
tests/python/codegen/llvm/test_basic.py:[0, 2]) now compiles;-1sentinels to detect writes to inactive lanes.float32,int8andfloat64. This catches a wrong predicate lane, which the 2-lane tests cannot, and covers the element type and alignment of the<1 x T>access.tests/python/codegen/llvmon Linux x86_64, compared againstmain(c4fbd89):mainThe 4 failures on LLVM 20 are
test_aarch64.py::test_min/test_max(float,float16) and are the same onmain.