void foo(double *d, double *a) {
  d[0] += d[2];
  d[1] += d[3];
  d[2] += d[4];
  d[3] += d[5];
  a[0] = d[0];
  a[1] = d[1];
}


x86 assembly (clang, -O0):
<foo>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x8(%rbp),%rax
addsd  (%rax),%xmm0
movsd  %xmm0,(%rax)
mov    -0x8(%rbp),%rax
movsd  0x18(%rax),%xmm0
mov    -0x8(%rbp),%rax
addsd  0x8(%rax),%xmm0
movsd  %xmm0,0x8(%rax)
mov    -0x8(%rbp),%rax
movsd  0x20(%rax),%xmm0
mov    -0x8(%rbp),%rax
addsd  0x10(%rax),%xmm0
movsd  %xmm0,0x10(%rax)
mov    -0x8(%rbp),%rax
movsd  0x28(%rax),%xmm0
mov    -0x8(%rbp),%rax
addsd  0x18(%rax),%xmm0
movsd  %xmm0,0x18(%rax)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x8(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<foo>:
movupd (%rdi),%xmm0
movupd 0x10(%rdi),%xmm1
movupd 0x20(%rdi),%xmm2
addpd  %xmm1,%xmm0
movupd %xmm0,(%rdi)
addpd  %xmm1,%xmm2
movupd %xmm2,0x10(%rdi)
movlpd %xmm0,(%rsi)
movsd  0x8(%rdi),%xmm0
movsd  %xmm0,0x8(%rsi)
ret

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

LLVM IR (-O2):
define void @foo(double* nocapture %0, double* nocapture writeonly %1) {
%3 = getelementptr inbounds double, double* %0, i64 2
%4 = bitcast double* %3 to <2 x double>*
%5 = load <2 x double>, <2 x double>* %4
%6 = getelementptr inbounds double, double* %0, i64 1
%7 = bitcast double* %0 to <2 x double>*
%8 = load <2 x double>, <2 x double>* %7
%9 = fadd <2 x double> %5, %8
%10 = bitcast double* %0 to <2 x double>*
store <2 x double> %9, <2 x double>* %10
%11 = getelementptr inbounds double, double* %0, i64 4
%12 = bitcast double* %11 to <2 x double>*
%13 = load <2 x double>, <2 x double>* %12
%14 = fadd <2 x double> %5, %13
%15 = bitcast double* %3 to <2 x double>*
store <2 x double> %14, <2 x double>* %15
%16 = extractelement <2 x double> %9, i64 0
store double %16, double* %1
%17 = load double, double* %6
%18 = getelementptr inbounds double, double* %1, i64 1
store double %17, double* %18
ret void
}