You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently int index = j * stride + i; recomputes j * stride for every i in the inner loop. The optimizer should hoist this but often doesn't with fl::size (size_t) plus non-restricted aliasing on curr/next.
Explicit hoist + restrict makes the dependency clear:
for (fl::size j = 1; j <= height; ++j) {
consti32 row = j * stride;
consti16* __restrict__ row_curr = curr + row;
consti16* __restrict__ row_above = curr + row - stride;
consti16* __restrict__ row_below = curr + row + stride;
i16* __restrict__ row_next = next + row;
for (fl::size i = 1; i <= width; ++i) {
consti32 c = row_curr[i];
i32 lap = row_curr[i+1] + row_curr[i-1]
+ row_above[i] + row_below[i]
- (c << 2);
// ... rest of inner body unchanged
}
}
Acceptance
bash test fl_math_wave_wave_simulation_real --cpp passes.
Generated assembly on -O2 shows the multiply lifted to the outer loop (verify with objdump -d or godbolt).
Relation
Bundle with §3 (#TBD — half-duplex fold-in); both touch the same inner loop body and the bundled diff is easier to review.
Activity
zackees commentedon Jun 15, 2026
Parent meta: #3098. Bundle with #3093 (§3 half-duplex fold-in) — same inner loop body.
perf(wave): hoist row arithmetic + FL_RESTRICT_PARAM in 2D update inn…