Quick answer: Annotation is no-op for NativeArray fields (Burst infers it). Use [NoAlias] on raw pointers / function params where alias analysis fails.
You add [NoAlias] expecting Burst to vectorize a hot loop. Inspector still shows scalar code. The real bottleneck wasn’t alias inference.
The Fix
[BurstCompile]
struct SimJob : IJobParallelFor {
public NativeArray<float> A; // Burst already knows non-aliasing
[ReadOnly] public NativeArray<float> B;
public void Execute(int i) => A[i] += B[i] * 2f;
}
// Where [NoAlias] does help
[BurstCompile]
static unsafe void Compute(
[NoAlias] float* a, [NoAlias] float* b, int n) {
for (int i = 0; i < n; i++) a[i] = b[i] + 1f;
}
Burst Inspector LLVM IR shows whether vectorization happened. If not, look at unrolling, math fast-mode, or struct layout instead.
Verifying
Open Burst Inspector, find the job. Vectorized SIMD instructions indicate optimization. Profiler ms drops accordingly.
“NoAlias is for pointers. NativeArray gets it free.”
Related Issues
For NativeArray dispose, see dispose. For ReadOnly write, see readonly.
Annotation for pointers. Inspector confirms.