void kernel_sgemv_n_4_vs_lib4(int kmax, float *A, float *x, int alg, float *y,
                              float *z, int km) {
  const int bs = 4;
  int k;
  float x_0, y_0 = 0, y_1 = 0, y_2 = 0, y_3 = 0;
  k = 0;
  for (; k < kmax - 3; k += 4) {
    x_0 = x[0];
    y_0 += A[0 + bs * 0] * x_0;
    y_1 += A[1 + bs * 0] * x_0;
    y_2 += A[2 + bs * 0] * x_0;
    y_3 += A[3 + bs * 0] * x_0;
    x_0 = x[1];
    y_0 += A[0 + bs * 1] * x_0;
    y_1 += A[1 + bs * 1] * x_0;
    y_2 += A[2 + bs * 1] * x_0;
    y_3 += A[3 + bs * 1] * x_0;
    x_0 = x[2];
    y_0 += A[0 + bs * 2] * x_0;
    y_1 += A[1 + bs * 2] * x_0;
    y_2 += A[2 + bs * 2] * x_0;
    y_3 += A[3 + bs * 2] * x_0;
    x_0 = x[3];
    y_0 += A[0 + bs * 3] * x_0;
    y_1 += A[1 + bs * 3] * x_0;
    y_2 += A[2 + bs * 3] * x_0;
    y_3 += A[3 + bs * 3] * x_0;
    A += 4 * bs;
    x += 4;
  }
  for (; k < kmax; k++) {
    x_0 = x[0];
    y_0 += A[0 + bs * 0] * x_0;
    y_1 += A[1 + bs * 0] * x_0;
    y_2 += A[2 + bs * 0] * x_0;
    y_3 += A[3 + bs * 0] * x_0;
    A += 1 * bs;
    x += 1;
  }
  if (alg == 0) {
    goto store;
  } else if (alg == 1) {
    y_0 += y[0];
    y_1 += y[1];
    y_2 += y[2];
    y_3 += y[3];
    goto store;
  } else {
    y_0 = y[0] - y_0;
    y_1 = y[1] - y_1;
    y_2 = y[2] - y_2;
    y_3 = y[3] - y_3;
    goto store;
  }
store:
  if (km >= 4) {
    z[0] = y_0;
    z[1] = y_1;
    z[2] = y_2;
    z[3] = y_3;
  } else {
    z[0] = y_0;
    if (km >= 2) {
      z[1] = y_1;
      if (km > 2) {
        z[2] = y_2;
      }
    }
  }
}


x86 assembly (clang, -O0):
<kernel_sgemv_n_4_vs_lib4>:
push   %rbp
mov    %rsp,%rbp
mov    0x10(%rbp),%eax
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
movl   $0x4,-0x34(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x40(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x44(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x48(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x4c(%rbp)
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
mov    -0x4(%rbp),%ecx
sub    $0x3,%ecx
cmp    %ecx,%eax
jge    13b8 <kernel_sgemv_n_4_vs_lib4+0x2b8>
mov    -0x18(%rbp),%rax
movss  (%rax),%xmm0
movss  %xmm0,-0x3c(%rbp)
mov    -0x10(%rbp),%rax
movss  (%rax),%xmm0
movss  -0x3c(%rbp),%xmm2
movss  -0x40(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x40(%rbp)
mov    -0x10(%rbp),%rax
movss  0x4(%rax),%xmm0
movss  -0x3c(%rbp),%xmm2
movss  -0x44(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x44(%rbp)
mov    -0x10(%rbp),%rax
movss  0x8(%rax),%xmm0
movss  -0x3c(%rbp),%xmm2
movss  -0x48(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x48(%rbp)
mov    -0x10(%rbp),%rax
movss  0xc(%rax),%xmm0
movss  -0x3c(%rbp),%xmm2
movss  -0x4c(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x4c(%rbp)
mov    -0x18(%rbp),%rax
movss  0x4(%rax),%xmm0
movss  %xmm0,-0x3c(%rbp)
mov    -0x10(%rbp),%rax
movss  0x10(%rax),%xmm0
movss  -0x3c(%rbp),%xmm2
movss  -0x40(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x40(%rbp)
mov    -0x10(%rbp),%rax
movss  0x14(%rax),%xmm0
movss  -0x3c(%rbp),%xmm2
movss  -0x44(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x44(%rbp)
mov    -0x10(%rbp),%rax
movss  0x18(%rax),%xmm0
movss  -0x3c(%rbp),%xmm2
movss  -0x48(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x48(%rbp)
mov    -0x10(%rbp),%rax
movss  0x1c(%rax),%xmm0
movss  -0x3c(%rbp),%xmm2
movss  -0x4c(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x4c(%rbp)
mov    -0x18(%rbp),%rax
movss  0x8(%rax),%xmm0
movss  %xmm0,-0x3c(%rbp)
mov    -0x10(%rbp),%rax
movss  0x20(%rax),%xmm0
movss  -0x3c(%rbp),%xmm2
movss  -0x40(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x40(%rbp)
mov    -0x10(%rbp),%rax
movss  0x24(%rax),%xmm0
movss  -0x3c(%rbp),%xmm2
movss  -0x44(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x44(%rbp)
mov    -0x10(%rbp),%rax
movss  0x28(%rax),%xmm0
movss  -0x3c(%rbp),%xmm2
movss  -0x48(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x48(%rbp)
mov    -0x10(%rbp),%rax
movss  0x2c(%rax),%xmm0
movss  -0x3c(%rbp),%xmm2
movss  -0x4c(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x4c(%rbp)
mov    -0x18(%rbp),%rax
movss  0xc(%rax),%xmm0
movss  %xmm0,-0x3c(%rbp)
mov    -0x10(%rbp),%rax
movss  0x30(%rax),%xmm0
movss  -0x3c(%rbp),%xmm2
movss  -0x40(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x40(%rbp)
mov    -0x10(%rbp),%rax
movss  0x34(%rax),%xmm0
movss  -0x3c(%rbp),%xmm2
movss  -0x44(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x44(%rbp)
mov    -0x10(%rbp),%rax
movss  0x38(%rax),%xmm0
movss  -0x3c(%rbp),%xmm2
movss  -0x48(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x48(%rbp)
mov    -0x10(%rbp),%rax
movss  0x3c(%rax),%xmm0
movss  -0x3c(%rbp),%xmm2
movss  -0x4c(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x4c(%rbp)
mov    -0x10(%rbp),%rax
add    $0x40,%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rax
add    $0x10,%rax
mov    %rax,-0x18(%rbp)
mov    -0x38(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0x38(%rbp)
jmp    114b <kernel_sgemv_n_4_vs_lib4+0x4b>
jmp    13bd <kernel_sgemv_n_4_vs_lib4+0x2bd>
mov    -0x38(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    147b <kernel_sgemv_n_4_vs_lib4+0x37b>
mov    -0x18(%rbp),%rax
movss  (%rax),%xmm0
movss  %xmm0,-0x3c(%rbp)
mov    -0x10(%rbp),%rax
movss  (%rax),%xmm0
movss  -0x3c(%rbp),%xmm2
movss  -0x40(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x40(%rbp)
mov    -0x10(%rbp),%rax
movss  0x4(%rax),%xmm0
movss  -0x3c(%rbp),%xmm2
movss  -0x44(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x44(%rbp)
mov    -0x10(%rbp),%rax
movss  0x8(%rax),%xmm0
movss  -0x3c(%rbp),%xmm2
movss  -0x48(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x48(%rbp)
mov    -0x10(%rbp),%rax
movss  0xc(%rax),%xmm0
movss  -0x3c(%rbp),%xmm2
movss  -0x4c(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x4c(%rbp)
mov    -0x10(%rbp),%rax
add    $0x10,%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x18(%rbp)
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    13bd <kernel_sgemv_n_4_vs_lib4+0x2bd>
cmpl   $0x0,-0x1c(%rbp)
jne    148a <kernel_sgemv_n_4_vs_lib4+0x38a>
jmp    152f <kernel_sgemv_n_4_vs_lib4+0x42f>
cmpl   $0x1,-0x1c(%rbp)
jne    14e4 <kernel_sgemv_n_4_vs_lib4+0x3e4>
mov    -0x28(%rbp),%rax
movss  (%rax),%xmm0
addss  -0x40(%rbp),%xmm0
movss  %xmm0,-0x40(%rbp)
mov    -0x28(%rbp),%rax
movss  0x4(%rax),%xmm0
addss  -0x44(%rbp),%xmm0
movss  %xmm0,-0x44(%rbp)
mov    -0x28(%rbp),%rax
movss  0x8(%rax),%xmm0
addss  -0x48(%rbp),%xmm0
movss  %xmm0,-0x48(%rbp)
mov    -0x28(%rbp),%rax
movss  0xc(%rax),%xmm0
addss  -0x4c(%rbp),%xmm0
movss  %xmm0,-0x4c(%rbp)
jmp    152f <kernel_sgemv_n_4_vs_lib4+0x42f>
mov    -0x28(%rbp),%rax
movss  (%rax),%xmm0
subss  -0x40(%rbp),%xmm0
movss  %xmm0,-0x40(%rbp)
mov    -0x28(%rbp),%rax
movss  0x4(%rax),%xmm0
subss  -0x44(%rbp),%xmm0
movss  %xmm0,-0x44(%rbp)
mov    -0x28(%rbp),%rax
movss  0x8(%rax),%xmm0
subss  -0x48(%rbp),%xmm0
movss  %xmm0,-0x48(%rbp)
mov    -0x28(%rbp),%rax
movss  0xc(%rax),%xmm0
subss  -0x4c(%rbp),%xmm0
movss  %xmm0,-0x4c(%rbp)
cmpl   $0x4,0x10(%rbp)
jl     1575 <kernel_sgemv_n_4_vs_lib4+0x475>
movss  -0x40(%rbp),%xmm0
mov    -0x30(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0x44(%rbp),%xmm0
mov    -0x30(%rbp),%rax
movss  %xmm0,0x4(%rax)
movss  -0x48(%rbp),%xmm0
mov    -0x30(%rbp),%rax
movss  %xmm0,0x8(%rax)
movss  -0x4c(%rbp),%xmm0
mov    -0x30(%rbp),%rax
movss  %xmm0,0xc(%rax)
jmp    15bc <kernel_sgemv_n_4_vs_lib4+0x4bc>
movss  -0x40(%rbp),%xmm0
mov    -0x30(%rbp),%rax
movss  %xmm0,(%rax)
cmpl   $0x2,0x10(%rbp)
jl     15b7 <kernel_sgemv_n_4_vs_lib4+0x4b7>
movss  -0x44(%rbp),%xmm0
mov    -0x30(%rbp),%rax
movss  %xmm0,0x4(%rax)
cmpl   $0x2,0x10(%rbp)
jle    15b2 <kernel_sgemv_n_4_vs_lib4+0x4b2>
movss  -0x48(%rbp),%xmm0
mov    -0x30(%rbp),%rax
movss  %xmm0,0x8(%rax)
jmp    15b7 <kernel_sgemv_n_4_vs_lib4+0x4b7>
jmp    15bc <kernel_sgemv_n_4_vs_lib4+0x4bc>
pop    %rbp
ret

x86 assembly (clang, -O2):
<kernel_sgemv_n_4_vs_lib4>:
cmp    $0x4,%edi
jl     1183 <kernel_sgemv_n_4_vs_lib4+0x83>
lea    -0x3(%rdi),%r10d
xorps  %xmm2,%xmm2
xor    %eax,%eax
xchg   %ax,%ax
movups (%rsi),%xmm3
movups 0x10(%rsi),%xmm4
movups 0x20(%rsi),%xmm5
movups 0x30(%rsi),%xmm8
movss  (%rdx),%xmm7
movss  0x4(%rdx),%xmm6
movss  0x8(%rdx),%xmm0
movss  0xc(%rdx),%xmm1
shufps $0x0,%xmm7,%xmm7
mulps  %xmm3,%xmm7
addps  %xmm2,%xmm7
shufps $0x0,%xmm6,%xmm6
mulps  %xmm4,%xmm6
addps  %xmm7,%xmm6
shufps $0x0,%xmm0,%xmm0
mulps  %xmm5,%xmm0
addps  %xmm6,%xmm0
shufps $0x0,%xmm1,%xmm1
mulps  %xmm8,%xmm1
movaps %xmm1,%xmm2
addps  %xmm0,%xmm2
add    $0x40,%rsi
add    $0x10,%rdx
add    $0x4,%eax
cmp    %r10d,%eax
jl     1110 <kernel_sgemv_n_4_vs_lib4+0x10>
addps  %xmm0,%xmm1
mov    %edi,%eax
and    $0xfffffffc,%eax
cmp    %edi,%eax
jl     118c <kernel_sgemv_n_4_vs_lib4+0x8c>
movaps %xmm1,%xmm0
jmp    1208 <kernel_sgemv_n_4_vs_lib4+0x108>
xorps  %xmm1,%xmm1
xor    %eax,%eax
cmp    %edi,%eax
jge    117b <kernel_sgemv_n_4_vs_lib4+0x7b>
mov    %eax,%r10d
not    %r10d
test   $0x1,%dil
jne    119f <kernel_sgemv_n_4_vs_lib4+0x9f>
add    %edi,%r10d
jne    11c3 <kernel_sgemv_n_4_vs_lib4+0xc3>
jmp    1208 <kernel_sgemv_n_4_vs_lib4+0x108>
movups (%rsi),%xmm2
movss  (%rdx),%xmm0
shufps $0x0,%xmm0,%xmm0
mulps  %xmm2,%xmm0
addps  %xmm1,%xmm0
add    $0x10,%rsi
add    $0x4,%rdx
or     $0x1,%eax
movaps %xmm0,%xmm1
add    %edi,%r10d
je     1208 <kernel_sgemv_n_4_vs_lib4+0x108>
sub    %eax,%edi
xor    %eax,%eax
nopw   0x0(%rax,%rax,1)
movss  (%rdx,%rax,4),%xmm3
movss  0x4(%rdx,%rax,4),%xmm0
shufps $0x0,%xmm3,%xmm3
movups (%rsi),%xmm2
mulps  %xmm3,%xmm2
addps  %xmm1,%xmm2
movups 0x10(%rsi),%xmm1
shufps $0x0,%xmm0,%xmm0
mulps  %xmm1,%xmm0
movaps %xmm0,%xmm1
addps  %xmm2,%xmm1
add    $0x2,%rax
add    $0x20,%rsi
cmp    %eax,%edi
jne    11d0 <kernel_sgemv_n_4_vs_lib4+0xd0>
addps  %xmm2,%xmm0
mov    0x8(%rsp),%eax
test   %ecx,%ecx
je     1228 <kernel_sgemv_n_4_vs_lib4+0x128>
cmp    $0x1,%ecx
jne    121e <kernel_sgemv_n_4_vs_lib4+0x11e>
movups (%r8),%xmm1
addps  %xmm1,%xmm0
jmp    1228 <kernel_sgemv_n_4_vs_lib4+0x128>
movups (%r8),%xmm1
subps  %xmm0,%xmm1
movaps %xmm1,%xmm0
movss  %xmm0,(%r9)
cmp    $0x4,%eax
jl     1257 <kernel_sgemv_n_4_vs_lib4+0x157>
movaps %xmm0,%xmm1
shufps $0x55,%xmm0,%xmm1
movss  %xmm1,0x4(%r9)
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm1
movss  %xmm1,0x8(%r9)
shufps $0xff,%xmm0,%xmm0
mov    $0x3,%eax
jmp    1273 <kernel_sgemv_n_4_vs_lib4+0x173>
cmp    $0x2,%eax
jl     1279 <kernel_sgemv_n_4_vs_lib4+0x179>
movaps %xmm0,%xmm1
shufps $0x55,%xmm0,%xmm1
movss  %xmm1,0x4(%r9)
je     1279 <kernel_sgemv_n_4_vs_lib4+0x179>
movhlps %xmm0,%xmm0
mov    $0x2,%eax
movss  %xmm0,(%r9,%rax,4)
ret

LLVM IR (-O0):
define void @kernel_sgemv_n_4_vs_lib4(i32 %0, float* %1, float* %2, i32 %3, float* %4, float* %5, i32 %6) {
%8 = alloca i32
%9 = alloca float*
%10 = alloca float*
%11 = alloca i32
%12 = alloca float*
%13 = alloca float*
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca float
%18 = alloca float
%19 = alloca float
%20 = alloca float
%21 = alloca float
store i32 %0, i32* %8
store float* %1, float** %9
store float* %2, float** %10
store i32 %3, i32* %11
store float* %4, float** %12
store float* %5, float** %13
store i32 %6, i32* %14
store i32 4, i32* %15
store float 0.000000e+00, float* %18
store float 0.000000e+00, float* %19
store float 0.000000e+00, float* %20
store float 0.000000e+00, float* %21
store i32 0, i32* %16
br label %22
22: ; preds = %140, %7
%23 = load i32, i32* %16
%24 = load i32, i32* %8
%25 = sub nsw i32 %24, 3
%26 = icmp slt i32 %23, %25
br i1 %26, label %27, label %143
27: ; preds = %22
%28 = load float*, float** %10
%29 = getelementptr inbounds float, float* %28, i64 0
%30 = load float, float* %29
store float %30, float* %17
%31 = load float*, float** %9
%32 = getelementptr inbounds float, float* %31, i64 0
%33 = load float, float* %32
%34 = load float, float* %17
%35 = load float, float* %18
%36 = call float @llvm.fmuladd.f32(float %33, float %34, float %35)
store float %36, float* %18
%37 = load float*, float** %9
%38 = getelementptr inbounds float, float* %37, i64 1
%39 = load float, float* %38
%40 = load float, float* %17
%41 = load float, float* %19
%42 = call float @llvm.fmuladd.f32(float %39, float %40, float %41)
store float %42, float* %19
%43 = load float*, float** %9
%44 = getelementptr inbounds float, float* %43, i64 2
%45 = load float, float* %44
%46 = load float, float* %17
%47 = load float, float* %20
%48 = call float @llvm.fmuladd.f32(float %45, float %46, float %47)
store float %48, float* %20
%49 = load float*, float** %9
%50 = getelementptr inbounds float, float* %49, i64 3
%51 = load float, float* %50
%52 = load float, float* %17
%53 = load float, float* %21
%54 = call float @llvm.fmuladd.f32(float %51, float %52, float %53)
store float %54, float* %21
%55 = load float*, float** %10
%56 = getelementptr inbounds float, float* %55, i64 1
%57 = load float, float* %56
store float %57, float* %17
%58 = load float*, float** %9
%59 = getelementptr inbounds float, float* %58, i64 4
%60 = load float, float* %59
%61 = load float, float* %17
%62 = load float, float* %18
%63 = call float @llvm.fmuladd.f32(float %60, float %61, float %62)
store float %63, float* %18
%64 = load float*, float** %9
%65 = getelementptr inbounds float, float* %64, i64 5
%66 = load float, float* %65
%67 = load float, float* %17
%68 = load float, float* %19
%69 = call float @llvm.fmuladd.f32(float %66, float %67, float %68)
store float %69, float* %19
%70 = load float*, float** %9
%71 = getelementptr inbounds float, float* %70, i64 6
%72 = load float, float* %71
%73 = load float, float* %17
%74 = load float, float* %20
%75 = call float @llvm.fmuladd.f32(float %72, float %73, float %74)
store float %75, float* %20
%76 = load float*, float** %9
%77 = getelementptr inbounds float, float* %76, i64 7
%78 = load float, float* %77
%79 = load float, float* %17
%80 = load float, float* %21
%81 = call float @llvm.fmuladd.f32(float %78, float %79, float %80)
store float %81, float* %21
%82 = load float*, float** %10
%83 = getelementptr inbounds float, float* %82, i64 2
%84 = load float, float* %83
store float %84, float* %17
%85 = load float*, float** %9
%86 = getelementptr inbounds float, float* %85, i64 8
%87 = load float, float* %86
%88 = load float, float* %17
%89 = load float, float* %18
%90 = call float @llvm.fmuladd.f32(float %87, float %88, float %89)
store float %90, float* %18
%91 = load float*, float** %9
%92 = getelementptr inbounds float, float* %91, i64 9
%93 = load float, float* %92
%94 = load float, float* %17
%95 = load float, float* %19
%96 = call float @llvm.fmuladd.f32(float %93, float %94, float %95)
store float %96, float* %19
%97 = load float*, float** %9
%98 = getelementptr inbounds float, float* %97, i64 10
%99 = load float, float* %98
%100 = load float, float* %17
%101 = load float, float* %20
%102 = call float @llvm.fmuladd.f32(float %99, float %100, float %101)
store float %102, float* %20
%103 = load float*, float** %9
%104 = getelementptr inbounds float, float* %103, i64 11
%105 = load float, float* %104
%106 = load float, float* %17
%107 = load float, float* %21
%108 = call float @llvm.fmuladd.f32(float %105, float %106, float %107)
store float %108, float* %21
%109 = load float*, float** %10
%110 = getelementptr inbounds float, float* %109, i64 3
%111 = load float, float* %110
store float %111, float* %17
%112 = load float*, float** %9
%113 = getelementptr inbounds float, float* %112, i64 12
%114 = load float, float* %113
%115 = load float, float* %17
%116 = load float, float* %18
%117 = call float @llvm.fmuladd.f32(float %114, float %115, float %116)
store float %117, float* %18
%118 = load float*, float** %9
%119 = getelementptr inbounds float, float* %118, i64 13
%120 = load float, float* %119
%121 = load float, float* %17
%122 = load float, float* %19
%123 = call float @llvm.fmuladd.f32(float %120, float %121, float %122)
store float %123, float* %19
%124 = load float*, float** %9
%125 = getelementptr inbounds float, float* %124, i64 14
%126 = load float, float* %125
%127 = load float, float* %17
%128 = load float, float* %20
%129 = call float @llvm.fmuladd.f32(float %126, float %127, float %128)
store float %129, float* %20
%130 = load float*, float** %9
%131 = getelementptr inbounds float, float* %130, i64 15
%132 = load float, float* %131
%133 = load float, float* %17
%134 = load float, float* %21
%135 = call float @llvm.fmuladd.f32(float %132, float %133, float %134)
store float %135, float* %21
%136 = load float*, float** %9
%137 = getelementptr inbounds float, float* %136, i64 16
store float* %137, float** %9
%138 = load float*, float** %10
%139 = getelementptr inbounds float, float* %138, i64 4
store float* %139, float** %10
br label %140
140: ; preds = %27
%141 = load i32, i32* %16
%142 = add nsw i32 %141, 4
store i32 %142, i32* %16
br label %22
143: ; preds = %22
br label %144
144: ; preds = %180, %143
%145 = load i32, i32* %16
%146 = load i32, i32* %8
%147 = icmp slt i32 %145, %146
br i1 %147, label %148, label %183
148: ; preds = %144
%149 = load float*, float** %10
%150 = getelementptr inbounds float, float* %149, i64 0
%151 = load float, float* %150
store float %151, float* %17
%152 = load float*, float** %9
%153 = getelementptr inbounds float, float* %152, i64 0
%154 = load float, float* %153
%155 = load float, float* %17
%156 = load float, float* %18
%157 = call float @llvm.fmuladd.f32(float %154, float %155, float %156)
store float %157, float* %18
%158 = load float*, float** %9
%159 = getelementptr inbounds float, float* %158, i64 1
%160 = load float, float* %159
%161 = load float, float* %17
%162 = load float, float* %19
%163 = call float @llvm.fmuladd.f32(float %160, float %161, float %162)
store float %163, float* %19
%164 = load float*, float** %9
%165 = getelementptr inbounds float, float* %164, i64 2
%166 = load float, float* %165
%167 = load float, float* %17
%168 = load float, float* %20
%169 = call float @llvm.fmuladd.f32(float %166, float %167, float %168)
store float %169, float* %20
%170 = load float*, float** %9
%171 = getelementptr inbounds float, float* %170, i64 3
%172 = load float, float* %171
%173 = load float, float* %17
%174 = load float, float* %21
%175 = call float @llvm.fmuladd.f32(float %172, float %173, float %174)
store float %175, float* %21
%176 = load float*, float** %9
%177 = getelementptr inbounds float, float* %176, i64 4
store float* %177, float** %9
%178 = load float*, float** %10
%179 = getelementptr inbounds float, float* %178, i64 1
store float* %179, float** %10
br label %180
180: ; preds = %148
%181 = load i32, i32* %16
%182 = add nsw i32 %181, 1
store i32 %182, i32* %16
br label %144
183: ; preds = %144
%184 = load i32, i32* %11
%185 = icmp eq i32 %184, 0
br i1 %185, label %186, label %187
186: ; preds = %183
br label %232
187: ; preds = %183
%188 = load i32, i32* %11
%189 = icmp eq i32 %188, 1
br i1 %189, label %190, label %211
190: ; preds = %187
%191 = load float*, float** %12
%192 = getelementptr inbounds float, float* %191, i64 0
%193 = load float, float* %192
%194 = load float, float* %18
%195 = fadd float %194, %193
store float %195, float* %18
%196 = load float*, float** %12
%197 = getelementptr inbounds float, float* %196, i64 1
%198 = load float, float* %197
%199 = load float, float* %19
%200 = fadd float %199, %198
store float %200, float* %19
%201 = load float*, float** %12
%202 = getelementptr inbounds float, float* %201, i64 2
%203 = load float, float* %202
%204 = load float, float* %20
%205 = fadd float %204, %203
store float %205, float* %20
%206 = load float*, float** %12
%207 = getelementptr inbounds float, float* %206, i64 3
%208 = load float, float* %207
%209 = load float, float* %21
%210 = fadd float %209, %208
store float %210, float* %21
br label %232
211: ; preds = %187
%212 = load float*, float** %12
%213 = getelementptr inbounds float, float* %212, i64 0
%214 = load float, float* %213
%215 = load float, float* %18
%216 = fsub float %214, %215
store float %216, float* %18
%217 = load float*, float** %12
%218 = getelementptr inbounds float, float* %217, i64 1
%219 = load float, float* %218
%220 = load float, float* %19
%221 = fsub float %219, %220
store float %221, float* %19
%222 = load float*, float** %12
%223 = getelementptr inbounds float, float* %222, i64 2
%224 = load float, float* %223
%225 = load float, float* %20
%226 = fsub float %224, %225
store float %226, float* %20
%227 = load float*, float** %12
%228 = getelementptr inbounds float, float* %227, i64 3
%229 = load float, float* %228
%230 = load float, float* %21
%231 = fsub float %229, %230
store float %231, float* %21
br label %232
232: ; preds = %211, %190, %186
%233 = load i32, i32* %14
%234 = icmp sge i32 %233, 4
br i1 %234, label %235, label %248
235: ; preds = %232
%236 = load float, float* %18
%237 = load float*, float** %13
%238 = getelementptr inbounds float, float* %237, i64 0
store float %236, float* %238
%239 = load float, float* %19
%240 = load float*, float** %13
%241 = getelementptr inbounds float, float* %240, i64 1
store float %239, float* %241
%242 = load float, float* %20
%243 = load float*, float** %13
%244 = getelementptr inbounds float, float* %243, i64 2
store float %242, float* %244
%245 = load float, float* %21
%246 = load float*, float** %13
%247 = getelementptr inbounds float, float* %246, i64 3
store float %245, float* %247
br label %266
248: ; preds = %232
%249 = load float, float* %18
%250 = load float*, float** %13
%251 = getelementptr inbounds float, float* %250, i64 0
store float %249, float* %251
%252 = load i32, i32* %14
%253 = icmp sge i32 %252, 2
br i1 %253, label %254, label %265
254: ; preds = %248
%255 = load float, float* %19
%256 = load float*, float** %13
%257 = getelementptr inbounds float, float* %256, i64 1
store float %255, float* %257
%258 = load i32, i32* %14
%259 = icmp sgt i32 %258, 2
br i1 %259, label %260, label %264
260: ; preds = %254
%261 = load float, float* %20
%262 = load float*, float** %13
%263 = getelementptr inbounds float, float* %262, i64 2
store float %261, float* %263
br label %264
264: ; preds = %260, %254
br label %265
265: ; preds = %264, %248
br label %266
266: ; preds = %265, %235
ret void
}

LLVM IR (-O2):
define void @kernel_sgemv_n_4_vs_lib4(i32 %0, float* nocapture %1, float* nocapture %2, i32 %3, float* nocapture %4, float* nocapture writeonly %5, i32 %6) {
%8 = add nsw i32 %0, -3
%9 = icmp sgt i32 %0, 3
br i1 %9, label %45, label %16
10: ; preds = %45
%11 = call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %52, <4 x float> %54, <4 x float> %49)
%12 = call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %60, <4 x float> %62, <4 x float> %11)
%13 = call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %68, <4 x float> %70, <4 x float> %12)
%14 = call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %76, <4 x float> %78, <4 x float> %13)
%15 = and i32 %0, -4
br label %16
16: ; preds = %10, %7
%17 = phi float* [ %2, %7 ], [ %81, %10 ]
%18 = phi float* [ %1, %7 ], [ %80, %10 ]
%19 = phi i32 [ 0, %7 ], [ %15, %10 ]
%20 = phi <4 x float> [ zeroinitializer, %7 ], [ %14, %10 ]
%21 = icmp slt i32 %19, %0
br i1 %21, label %22, label %109
22: ; preds = %16
%23 = xor i32 %19, -1
%24 = and i32 %0, 1
%25 = icmp eq i32 %24, 0
br i1 %25, label %37, label %26
26: ; preds = %22
%27 = load float, float* %17
%28 = bitcast float* %18 to <4 x float>*
%29 = load <4 x float>, <4 x float>* %28
%30 = insertelement <4 x float> poison, float %27, i64 0
%31 = shufflevector <4 x float> %30, <4 x float> poison, <4 x i32> zeroinitializer
%32 = call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %29, <4 x float> %31, <4 x float> %20)
%33 = call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %29, <4 x float> %31, <4 x float> %20)
%34 = getelementptr inbounds float, float* %18, i64 4
%35 = getelementptr inbounds float, float* %17, i64 1
%36 = or i32 %19, 1
br label %37
37: ; preds = %26, %22
%38 = phi <4 x float> [ undef, %22 ], [ %33, %26 ]
%39 = phi i32 [ %19, %22 ], [ %36, %26 ]
%40 = phi float* [ %18, %22 ], [ %34, %26 ]
%41 = phi float* [ %17, %22 ], [ %35, %26 ]
%42 = phi <4 x float> [ %20, %22 ], [ %32, %26 ]
%43 = sub i32 0, %0
%44 = icmp eq i32 %23, %43
br i1 %44, label %109, label %84
45: ; preds = %7, %45
%46 = phi i32 [ %82, %45 ], [ 0, %7 ]
%47 = phi float* [ %80, %45 ], [ %1, %7 ]
%48 = phi float* [ %81, %45 ], [ %2, %7 ]
%49 = phi <4 x float> [ %79, %45 ], [ zeroinitializer, %7 ]
%50 = load float, float* %48
%51 = bitcast float* %47 to <4 x float>*
%52 = load <4 x float>, <4 x float>* %51
%53 = insertelement <4 x float> poison, float %50, i64 0
%54 = shufflevector <4 x float> %53, <4 x float> poison, <4 x i32> zeroinitializer
%55 = call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %52, <4 x float> %54, <4 x float> %49)
%56 = getelementptr inbounds float, float* %48, i64 1
%57 = load float, float* %56
%58 = getelementptr inbounds float, float* %47, i64 4
%59 = bitcast float* %58 to <4 x float>*
%60 = load <4 x float>, <4 x float>* %59
%61 = insertelement <4 x float> poison, float %57, i64 0
%62 = shufflevector <4 x float> %61, <4 x float> poison, <4 x i32> zeroinitializer
%63 = call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %60, <4 x float> %62, <4 x float> %55)
%64 = getelementptr inbounds float, float* %48, i64 2
%65 = load float, float* %64
%66 = getelementptr inbounds float, float* %47, i64 8
%67 = bitcast float* %66 to <4 x float>*
%68 = load <4 x float>, <4 x float>* %67
%69 = insertelement <4 x float> poison, float %65, i64 0
%70 = shufflevector <4 x float> %69, <4 x float> poison, <4 x i32> zeroinitializer
%71 = call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %68, <4 x float> %70, <4 x float> %63)
%72 = getelementptr inbounds float, float* %48, i64 3
%73 = load float, float* %72
%74 = getelementptr inbounds float, float* %47, i64 12
%75 = bitcast float* %74 to <4 x float>*
%76 = load <4 x float>, <4 x float>* %75
%77 = insertelement <4 x float> poison, float %73, i64 0
%78 = shufflevector <4 x float> %77, <4 x float> poison, <4 x i32> zeroinitializer
%79 = call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %76, <4 x float> %78, <4 x float> %71)
%80 = getelementptr inbounds float, float* %47, i64 16
%81 = getelementptr inbounds float, float* %48, i64 4
%82 = add nuw nsw i32 %46, 4
%83 = icmp slt i32 %82, %8
br i1 %83, label %45, label %10
84: ; preds = %37, %84
%85 = phi i32 [ %105, %84 ], [ %39, %37 ]
%86 = phi float* [ %103, %84 ], [ %40, %37 ]
%87 = phi float* [ %104, %84 ], [ %41, %37 ]
%88 = phi <4 x float> [ %102, %84 ], [ %42, %37 ]
%89 = load float, float* %87
%90 = bitcast float* %86 to <4 x float>*
%91 = load <4 x float>, <4 x float>* %90
%92 = insertelement <4 x float> poison, float %89, i64 0
%93 = shufflevector <4 x float> %92, <4 x float> poison, <4 x i32> zeroinitializer
%94 = call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %91, <4 x float> %93, <4 x float> %88)
%95 = getelementptr inbounds float, float* %86, i64 4
%96 = getelementptr inbounds float, float* %87, i64 1
%97 = load float, float* %96
%98 = bitcast float* %95 to <4 x float>*
%99 = load <4 x float>, <4 x float>* %98
%100 = insertelement <4 x float> poison, float %97, i64 0
%101 = shufflevector <4 x float> %100, <4 x float> poison, <4 x i32> zeroinitializer
%102 = call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %99, <4 x float> %101, <4 x float> %94)
%103 = getelementptr inbounds float, float* %86, i64 8
%104 = getelementptr inbounds float, float* %87, i64 2
%105 = add nuw nsw i32 %85, 2
%106 = icmp eq i32 %105, %0
br i1 %106, label %107, label %84
107: ; preds = %84
%108 = call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %99, <4 x float> %101, <4 x float> %94)
br label %109
109: ; preds = %107, %37, %16
%110 = phi <4 x float> [ %20, %16 ], [ %38, %37 ], [ %108, %107 ]
switch i32 %3, label %115 [
i32 0, label %119
i32 1, label %111
]
111: ; preds = %109
%112 = bitcast float* %4 to <4 x float>*
%113 = load <4 x float>, <4 x float>* %112
%114 = fadd <4 x float> %110, %113
br label %119
115: ; preds = %109
%116 = bitcast float* %4 to <4 x float>*
%117 = load <4 x float>, <4 x float>* %116
%118 = fsub <4 x float> %117, %110
br label %119
119: ; preds = %109, %115, %111
%120 = phi <4 x float> [ %110, %109 ], [ %114, %111 ], [ %118, %115 ]
%121 = icmp sgt i32 %6, 3
%122 = extractelement <4 x float> %120, i64 0
store float %122, float* %5
br i1 %121, label %123, label %129
123: ; preds = %119
%124 = getelementptr inbounds float, float* %5, i64 1
%125 = extractelement <4 x float> %120, i64 1
store float %125, float* %124
%126 = getelementptr inbounds float, float* %5, i64 2
%127 = extractelement <4 x float> %120, i64 2
store float %127, float* %126
%128 = extractelement <4 x float> %120, i64 3
br label %136
129: ; preds = %119
%130 = icmp sgt i32 %6, 1
br i1 %130, label %131, label %140
131: ; preds = %129
%132 = getelementptr inbounds float, float* %5, i64 1
%133 = extractelement <4 x float> %120, i64 1
store float %133, float* %132
%134 = icmp eq i32 %6, 2
%135 = extractelement <4 x float> %120, i64 2
br i1 %134, label %140, label %136
136: ; preds = %131, %123
%137 = phi i64 [ 3, %123 ], [ 2, %131 ]
%138 = phi float [ %128, %123 ], [ %135, %131 ]
%139 = getelementptr inbounds float, float* %5, i64 %137
store float %138, float* %139
br label %140
140: ; preds = %136, %129, %131
ret void
}