; Hand-authored factor-2 unroll-and-jam plus shared-load reuse.
; Same simplified pointer ABI and assumptions as matvec-before.ll.
; No fast-math flags. Each row keeps its original j accumulation order.
define void @matvec(ptr readonly %W, ptr readonly %x, ptr noalias %y,
                    i64 %rows, i64 %cols) {
entry:
  %pairs = and i64 %rows, -2
  br label %pair
pair:
  %i = phi i64 [ 0, %entry ], [ %i.next, %pair.done ]
  %more.pairs = icmp slt i64 %i, %pairs
  br i1 %more.pairs, label %pair.start, label %tail.check
pair.start:
  %i1 = add i64 %i, 1
  %base0 = mul i64 %i, %cols
  %base1 = mul i64 %i1, %cols
  br label %column
column:
  %j = phi i64 [ 0, %pair.start ], [ %j.next, %body ]
  %acc0 = phi float [ 0.000000e+00, %pair.start ], [ %next0, %body ]
  %acc1 = phi float [ 0.000000e+00, %pair.start ], [ %next1, %body ]
  %more.cols = icmp slt i64 %j, %cols
  br i1 %more.cols, label %body, label %pair.done
body:
  %index0 = add i64 %base0, %j
  %index1 = add i64 %base1, %j
  %wp0 = getelementptr float, ptr %W, i64 %index0
  %wp1 = getelementptr float, ptr %W, i64 %index1
  %xp = getelementptr float, ptr %x, i64 %j
  %shared = load float, ptr %xp, align 4
  %w0 = load float, ptr %wp0, align 4
  %w1 = load float, ptr %wp1, align 4
  %product0 = fmul float %w0, %shared
  %product1 = fmul float %w1, %shared
  %next0 = fadd float %acc0, %product0
  %next1 = fadd float %acc1, %product1
  %j.next = add i64 %j, 1
  br label %column
pair.done:
  %yp0 = getelementptr float, ptr %y, i64 %i
  %yp1 = getelementptr float, ptr %y, i64 %i1
  store float %acc0, ptr %yp0, align 4
  store float %acc1, ptr %yp1, align 4
  %i.next = add i64 %i, 2
  br label %pair
tail.check:
  %has.tail = icmp slt i64 %pairs, %rows
  br i1 %has.tail, label %tail.start, label %exit
tail.start:
  %tail.base = mul i64 %pairs, %cols
  br label %tail.column
tail.column:
  %tj = phi i64 [ 0, %tail.start ], [ %tj.next, %tail.body ]
  %tacc = phi float [ 0.000000e+00, %tail.start ], [ %tnext, %tail.body ]
  %tail.more = icmp slt i64 %tj, %cols
  br i1 %tail.more, label %tail.body, label %tail.done
tail.body:
  %tindex = add i64 %tail.base, %tj
  %twp = getelementptr float, ptr %W, i64 %tindex
  %txp = getelementptr float, ptr %x, i64 %tj
  %tw = load float, ptr %twp, align 4
  %tv = load float, ptr %txp, align 4
  %tproduct = fmul float %tw, %tv
  %tnext = fadd float %tacc, %tproduct
  %tj.next = add i64 %tj, 1
  br label %tail.column
tail.done:
  %typ = getelementptr float, ptr %y, i64 %pairs
  store float %tacc, ptr %typ, align 4
  br label %exit
exit:
  ret void
}
