void matrix_vector_multiply_2x2_2d(const double m[4], const double v[2],
                                   double result[2]) {
  result[0] = m[0] * v[0] + m[1] * v[1];
  result[1] = m[2] * v[0] + m[3] * v[1];
}


x86 assembly (clang, -O0):
<matrix_vector_multiply_2x2_2d>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm2
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm1
mov    -0x10(%rbp),%rax
mulsd  0x8(%rax),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm2
mov    -0x8(%rbp),%rax
movsd  0x18(%rax),%xmm1
mov    -0x10(%rbp),%rax
mulsd  0x8(%rax),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x8(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<matrix_vector_multiply_2x2_2d>:
movsd  (%rdi),%xmm0
movsd  0x8(%rdi),%xmm1
mulsd  0x8(%rsi),%xmm1
mulsd  (%rsi),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rdx)
movsd  0x10(%rdi),%xmm0
movsd  0x18(%rdi),%xmm1
mulsd  0x8(%rsi),%xmm1
mulsd  (%rsi),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,0x8(%rdx)
ret

LLVM IR (-O0):
define void @matrix_vector_multiply_2x2_2d(double* %0, double* %1, double* %2) {
%4 = alloca double*
%5 = alloca double*
%6 = alloca double*
store double* %0, double** %4
store double* %1, double** %5
store double* %2, double** %6
%7 = load double*, double** %4
%8 = getelementptr inbounds double, double* %7, i64 0
%9 = load double, double* %8
%10 = load double*, double** %5
%11 = getelementptr inbounds double, double* %10, i64 0
%12 = load double, double* %11
%13 = load double*, double** %4
%14 = getelementptr inbounds double, double* %13, i64 1
%15 = load double, double* %14
%16 = load double*, double** %5
%17 = getelementptr inbounds double, double* %16, i64 1
%18 = load double, double* %17
%19 = fmul double %15, %18
%20 = call double @llvm.fmuladd.f64(double %9, double %12, double %19)
%21 = load double*, double** %6
%22 = getelementptr inbounds double, double* %21, i64 0
store double %20, double* %22
%23 = load double*, double** %4
%24 = getelementptr inbounds double, double* %23, i64 2
%25 = load double, double* %24
%26 = load double*, double** %5
%27 = getelementptr inbounds double, double* %26, i64 0
%28 = load double, double* %27
%29 = load double*, double** %4
%30 = getelementptr inbounds double, double* %29, i64 3
%31 = load double, double* %30
%32 = load double*, double** %5
%33 = getelementptr inbounds double, double* %32, i64 1
%34 = load double, double* %33
%35 = fmul double %31, %34
%36 = call double @llvm.fmuladd.f64(double %25, double %28, double %35)
%37 = load double*, double** %6
%38 = getelementptr inbounds double, double* %37, i64 1
store double %36, double* %38
ret void
}

LLVM IR (-O2):
define void @matrix_vector_multiply_2x2_2d(double* nocapture %0, double* nocapture %1, double* nocapture writeonly %2) {
%4 = load double, double* %0
%5 = load double, double* %1
%6 = getelementptr inbounds double, double* %0, i64 1
%7 = load double, double* %6
%8 = getelementptr inbounds double, double* %1, i64 1
%9 = load double, double* %8
%10 = fmul double %7, %9
%11 = tail call double @llvm.fmuladd.f64(double %4, double %5, double %10)
store double %11, double* %2
%12 = getelementptr inbounds double, double* %0, i64 2
%13 = load double, double* %12
%14 = load double, double* %1
%15 = getelementptr inbounds double, double* %0, i64 3
%16 = load double, double* %15
%17 = load double, double* %8
%18 = fmul double %16, %17
%19 = tail call double @llvm.fmuladd.f64(double %13, double %14, double %18)
%20 = getelementptr inbounds double, double* %2, i64 1
store double %19, double* %20
ret void
}