void foo(double *a, double *b) {
  int i;
#pragma omp simd aligned(a, b : 4 * sizeof(double))
  for (i = 0; i < 32768; i++)
    a[i] += b[i];
}


x86 assembly (clang, -O0):
<foo>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x8000,-0x14(%rbp)
jge    114d <foo+0x4d>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
addsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1113 <foo+0x13>
pop    %rbp
ret

x86 assembly (clang, -O2):
<foo>:
lea    0x40000(%rsi),%rax
cmp    %rdi,%rax
jbe    1173 <foo+0x73>
lea    0x40000(%rdi),%rax
cmp    %rsi,%rax
jbe    1173 <foo+0x73>
xor    %eax,%eax
nopw   0x0(%rax,%rax,1)
movsd  (%rsi,%rax,8),%xmm0
addsd  (%rdi,%rax,8),%xmm0
movsd  %xmm0,(%rdi,%rax,8)
movsd  0x8(%rsi,%rax,8),%xmm0
addsd  0x8(%rdi,%rax,8),%xmm0
movsd  %xmm0,0x8(%rdi,%rax,8)
movsd  0x10(%rsi,%rax,8),%xmm0
addsd  0x10(%rdi,%rax,8),%xmm0
movsd  %xmm0,0x10(%rdi,%rax,8)
movsd  0x18(%rsi,%rax,8),%xmm0
addsd  0x18(%rdi,%rax,8),%xmm0
movsd  %xmm0,0x18(%rdi,%rax,8)
add    $0x4,%rax
cmp    $0x8000,%rax
jne    1120 <foo+0x20>
jmp    11e1 <foo+0xe1>
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
nop
movupd (%rsi,%rax,8),%xmm0
movupd 0x10(%rsi,%rax,8),%xmm1
movupd (%rdi,%rax,8),%xmm2
addpd  %xmm0,%xmm2
movupd 0x10(%rdi,%rax,8),%xmm0
addpd  %xmm1,%xmm0
movupd 0x20(%rdi,%rax,8),%xmm1
movupd 0x30(%rdi,%rax,8),%xmm3
movupd %xmm2,(%rdi,%rax,8)
movupd %xmm0,0x10(%rdi,%rax,8)
movupd 0x20(%rsi,%rax,8),%xmm0
addpd  %xmm1,%xmm0
movupd 0x30(%rsi,%rax,8),%xmm1
addpd  %xmm3,%xmm1
movupd %xmm0,0x20(%rdi,%rax,8)
movupd %xmm1,0x30(%rdi,%rax,8)
add    $0x8,%rax
cmp    $0x8000,%rax
jne    1180 <foo+0x80>
ret

LLVM IR (-O0):
define void @foo(double* %0, double* %1) {
%3 = alloca double*
%4 = alloca double*
%5 = alloca i32
store double* %0, double** %3
store double* %1, double** %4
store i32 0, i32* %5
br label %6
6: ; preds = %21, %2
%7 = load i32, i32* %5
%8 = icmp slt i32 %7, 32768
br i1 %8, label %9, label %24
9: ; preds = %6
%10 = load double*, double** %4
%11 = load i32, i32* %5
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds double, double* %10, i64 %12
%14 = load double, double* %13
%15 = load double*, double** %3
%16 = load i32, i32* %5
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds double, double* %15, i64 %17
%19 = load double, double* %18
%20 = fadd double %19, %14
store double %20, double* %18
br label %21
21: ; preds = %9
%22 = load i32, i32* %5
%23 = add nsw i32 %22, 1
store i32 %23, i32* %5
br label %6
24: ; preds = %6
ret void
}

LLVM IR (-O2):
define void @foo(double* nocapture %0, double* nocapture %1) {
%3 = getelementptr double, double* %0, i64 32768
%4 = getelementptr double, double* %1, i64 32768
%5 = icmp ugt double* %4, %0
%6 = icmp ugt double* %3, %1
%7 = and i1 %5, %6
br i1 %7, label %45, label %8
8: ; preds = %2, %8
%9 = phi i64 [ %43, %8 ], [ 0, %2 ]
%10 = getelementptr inbounds double, double* %1, i64 %9
%11 = bitcast double* %10 to <2 x double>*
%12 = load <2 x double>, <2 x double>* %11
%13 = getelementptr inbounds double, double* %10, i64 2
%14 = bitcast double* %13 to <2 x double>*
%15 = load <2 x double>, <2 x double>* %14
%16 = getelementptr inbounds double, double* %0, i64 %9
%17 = bitcast double* %16 to <2 x double>*
%18 = load <2 x double>, <2 x double>* %17
%19 = getelementptr inbounds double, double* %16, i64 2
%20 = bitcast double* %19 to <2 x double>*
%21 = load <2 x double>, <2 x double>* %20
%22 = fadd <2 x double> %12, %18
%23 = fadd <2 x double> %15, %21
%24 = bitcast double* %16 to <2 x double>*
store <2 x double> %22, <2 x double>* %24
%25 = bitcast double* %19 to <2 x double>*
store <2 x double> %23, <2 x double>* %25
%26 = or i64 %9, 4
%27 = getelementptr inbounds double, double* %1, i64 %26
%28 = bitcast double* %27 to <2 x double>*
%29 = load <2 x double>, <2 x double>* %28
%30 = getelementptr inbounds double, double* %27, i64 2
%31 = bitcast double* %30 to <2 x double>*
%32 = load <2 x double>, <2 x double>* %31
%33 = getelementptr inbounds double, double* %0, i64 %26
%34 = bitcast double* %33 to <2 x double>*
%35 = load <2 x double>, <2 x double>* %34
%36 = getelementptr inbounds double, double* %33, i64 2
%37 = bitcast double* %36 to <2 x double>*
%38 = load <2 x double>, <2 x double>* %37
%39 = fadd <2 x double> %29, %35
%40 = fadd <2 x double> %32, %38
%41 = bitcast double* %33 to <2 x double>*
store <2 x double> %39, <2 x double>* %41
%42 = bitcast double* %36 to <2 x double>*
store <2 x double> %40, <2 x double>* %42
%43 = add nuw nsw i64 %9, 8
%44 = icmp eq i64 %43, 32768
br i1 %44, label %72, label %8
45: ; preds = %2, %45
%46 = phi i64 [ %70, %45 ], [ 0, %2 ]
%47 = getelementptr inbounds double, double* %1, i64 %46
%48 = load double, double* %47
%49 = getelementptr inbounds double, double* %0, i64 %46
%50 = load double, double* %49
%51 = fadd double %48, %50
store double %51, double* %49
%52 = or i64 %46, 1
%53 = getelementptr inbounds double, double* %1, i64 %52
%54 = load double, double* %53
%55 = getelementptr inbounds double, double* %0, i64 %52
%56 = load double, double* %55
%57 = fadd double %54, %56
store double %57, double* %55
%58 = or i64 %46, 2
%59 = getelementptr inbounds double, double* %1, i64 %58
%60 = load double, double* %59
%61 = getelementptr inbounds double, double* %0, i64 %58
%62 = load double, double* %61
%63 = fadd double %60, %62
store double %63, double* %61
%64 = or i64 %46, 3
%65 = getelementptr inbounds double, double* %1, i64 %64
%66 = load double, double* %65
%67 = getelementptr inbounds double, double* %0, i64 %64
%68 = load double, double* %67
%69 = fadd double %66, %68
store double %69, double* %67
%70 = add nuw nsw i64 %46, 4
%71 = icmp eq i64 %70, 32768
br i1 %71, label %72, label %45
72: ; preds = %8, %45
ret void
}