; Simplified pointer ABI for contiguous row-major buffers.
; rows/cols are non-negative. All addresses and products fit i64.
; y does not overlap W or x. W and x are read-only during this call.
define void @matvec(ptr readonly %W, ptr readonly %x, ptr noalias %y,
                    i64 %rows, i64 %cols) {
entry:
  br label %row
row:
  %i = phi i64 [ 0, %entry ], [ %i.next, %row.done ]
  %more.rows = icmp slt i64 %i, %rows
  br i1 %more.rows, label %row.start, label %exit
row.start:
  %base = mul i64 %i, %cols
  br label %column
column:
  %j = phi i64 [ 0, %row.start ], [ %j.next, %body ]
  %acc = phi float [ 0.000000e+00, %row.start ], [ %next, %body ]
  %more.cols = icmp slt i64 %j, %cols
  br i1 %more.cols, label %body, label %row.done
body:
  %index = add i64 %base, %j
  %wp = getelementptr float, ptr %W, i64 %index
  %xp = getelementptr float, ptr %x, i64 %j
  %w = load float, ptr %wp, align 4
  %v = load float, ptr %xp, align 4
  %product = fmul float %w, %v
  %next = fadd float %acc, %product
  %j.next = add i64 %j, 1
  br label %column
row.done:
  %yp = getelementptr float, ptr %y, i64 %i
  store float %acc, ptr %yp, align 4
  %i.next = add i64 %i, 1
  br label %row
exit:
  ret void
}
