What a `<N x T>` value is: the oracle types a parameter as a vector and an annotated local as one lane
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 14
- Forks
- 2
- Avg merge
- 12h 42m
- Merged PRs (30d)
- 61
Description
Two facts about Type::Simd (<4 x f32>) on the AST path that do not agree, found while sizing the last a parameter type decline in the flat corpus sweep (Vx#383).
A parameter is a vector. frontend/pass/trait_topologies.vx:
fn test_npu_transfer_vec(x: <4 x f32>) -> void { NPU {}.transfer_vector(x); }
func.func @test_npu_transfer_vec(%arg0: vector<4xf32>) {
%1 = call @NPU$transfer_vector(%0, %arg0) : (!llvm.struct<"NPU", ()>, vector<4xf32>) -> vector<4xf32>
An annotated local is one lane. backend/pass/simd_test.vx:
let v1 : <4 x f32> = *p1; // p1 : *mut f32
let v3 : <4 x f32> = v1 + v2;
*p3 = v3;
%0 = llvm.load %arg0 : !llvm.ptr -> f32
%2 = arith.addf %0, %1 : f32
llvm.store %2, %arg2 : f32, !llvm.ptr
The fixture pins the second form on purpose ("the SIMD add stays a single f32 addition in the frontend module; vectorization is a later pipeline's job"), and the flat path emits the same. But then the annotation on v1 means nothing, and a <4 x f32> is a vector in a signature and a scalar in a body. A caller passing a vector<4xf32> into a body that adds one lane is not a program anyone wrote.
The decision
Either <N x T> is a real vector type (a vector<NxT> SSA value; a load through *mut f32 into it is a vector.load of N lanes, arithmetic is lane-wise, and the simd fixture's expectation changes), or it is a hint the frontend erases (then a parameter of that type is f32 too, and trait_topologies.vx's signature changes). Which one is a language call.
The flat path
It declines the parameter (a parameter type), which is right until the type has one meaning. If the answer is "a real vector", the flat model grows an opaque vector variant first (parameter, argument, return, let; that covers every use in the corpus today), and lane arithmetic after. If the answer is "erased", lower_ty_synth maps it to the element and the decline goes away on its own.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with frontend/pass/trait_topologies.vx and backend/pass/simd_test.vx, then inspect the flat path's lower_ty_synth handling and the Type::Simd uses described in the issue. Determine whether is a real vector or an erased hint, and update the affected fixture expectations and flat model consistently. Done means parameters, locals, loads, arithmetic, returns, and arguments follow one documented meaning.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100