void foo(double *a) {
  for (int i = 0; i < 1000; i++)
    a[i] = 10;
}


x86 assembly (clang, -O0):
<foo>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x3e8,-0xc(%rbp)
jge    113f <foo+0x3f>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsd  0xed4(%rip),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    110f <foo+0xf>
pop    %rbp
ret

x86 assembly (clang, -O2):
<foo>:
mov    $0x12,%eax
movaps 0xef4(%rip),%xmm0
nopl   0x0(%rax)
movups %xmm0,-0x90(%rdi,%rax,8)
ff
movups %xmm0,-0x80(%rdi,%rax,8)
movups %xmm0,-0x70(%rdi,%rax,8)
movups %xmm0,-0x60(%rdi,%rax,8)
movups %xmm0,-0x50(%rdi,%rax,8)
movups %xmm0,-0x40(%rdi,%rax,8)
movups %xmm0,-0x30(%rdi,%rax,8)
movups %xmm0,-0x20(%rdi,%rax,8)
movups %xmm0,-0x10(%rdi,%rax,8)
movups %xmm0,(%rdi,%rax,8)
add    $0x14,%rax
cmp    $0x3fa,%rax
jne    1110 <foo+0x10>
ret

LLVM IR (-O0):
define void @foo(double* %0) {
%2 = alloca double*
%3 = alloca i32
store double* %0, double** %2
store i32 0, i32* %3
br label %4
4: ; preds = %12, %1
%5 = load i32, i32* %3
%6 = icmp slt i32 %5, 1000
br i1 %6, label %7, label %15
7: ; preds = %4
%8 = load double*, double** %2
%9 = load i32, i32* %3
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds double, double* %8, i64 %10
store double 1.000000e+01, double* %11
br label %12
12: ; preds = %7
%13 = load i32, i32* %3
%14 = add nsw i32 %13, 1
store i32 %14, i32* %3
br label %4
15: ; preds = %4
ret void
}

LLVM IR (-O2):
define void @foo(double* nocapture writeonly %0) {
br label %2
2: ; preds = %2, %1
%3 = phi i64 [ 0, %1 ], [ %28, %2 ]
%4 = getelementptr inbounds double, double* %0, i64 %3
%5 = bitcast double* %4 to <2 x double>*
store <2 x double> <double 1.000000e+01, double 1.000000e+01>, <2 x double>* %5
%6 = getelementptr inbounds double, double* %4, i64 2
%7 = bitcast double* %6 to <2 x double>*
store <2 x double> <double 1.000000e+01, double 1.000000e+01>, <2 x double>* %7
%8 = add nuw nsw i64 %3, 4
%9 = getelementptr inbounds double, double* %0, i64 %8
%10 = bitcast double* %9 to <2 x double>*
store <2 x double> <double 1.000000e+01, double 1.000000e+01>, <2 x double>* %10
%11 = getelementptr inbounds double, double* %9, i64 2
%12 = bitcast double* %11 to <2 x double>*
store <2 x double> <double 1.000000e+01, double 1.000000e+01>, <2 x double>* %12
%13 = add nuw nsw i64 %3, 8
%14 = getelementptr inbounds double, double* %0, i64 %13
%15 = bitcast double* %14 to <2 x double>*
store <2 x double> <double 1.000000e+01, double 1.000000e+01>, <2 x double>* %15
%16 = getelementptr inbounds double, double* %14, i64 2
%17 = bitcast double* %16 to <2 x double>*
store <2 x double> <double 1.000000e+01, double 1.000000e+01>, <2 x double>* %17
%18 = add nuw nsw i64 %3, 12
%19 = getelementptr inbounds double, double* %0, i64 %18
%20 = bitcast double* %19 to <2 x double>*
store <2 x double> <double 1.000000e+01, double 1.000000e+01>, <2 x double>* %20
%21 = getelementptr inbounds double, double* %19, i64 2
%22 = bitcast double* %21 to <2 x double>*
store <2 x double> <double 1.000000e+01, double 1.000000e+01>, <2 x double>* %22
%23 = add nuw nsw i64 %3, 16
%24 = getelementptr inbounds double, double* %0, i64 %23
%25 = bitcast double* %24 to <2 x double>*
store <2 x double> <double 1.000000e+01, double 1.000000e+01>, <2 x double>* %25
%26 = getelementptr inbounds double, double* %24, i64 2
%27 = bitcast double* %26 to <2 x double>*
store <2 x double> <double 1.000000e+01, double 1.000000e+01>, <2 x double>* %27
%28 = add nuw nsw i64 %3, 20
%29 = icmp eq i64 %28, 1000
br i1 %29, label %30, label %2
30: ; preds = %2
ret void
}