void kernel(double *v1, double *v2, int m) {
  double phi_e = *(v1 + 1);
  double phi_w = *(v1 - 1);
  double phi_n = *(v1 + m);
  double phi_s = *(v1 - m);
  double phi = 0.25 * (phi_e + phi_w + phi_n + phi_s);
  *(v2) = phi;
}


x86 assembly (clang, -O0):
<kernel>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movsd  -0x8(%rax),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rdx
xor    %ecx,%ecx
sub    %rdx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x20(%rbp),%xmm1
addsd  -0x28(%rbp),%xmm1
addsd  -0x30(%rbp),%xmm1
addsd  -0x38(%rbp),%xmm1
movsd  0xe90(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<kernel>:
movsd  0x8(%rdi),%xmm0
movslq %edx,%rax
addsd  -0x8(%rdi),%xmm0
addsd  (%rdi,%rax,8),%xmm0
lea    0x0(,%rax,8),%rax
sub    %rax,%rdi
addsd  (%rdi),%xmm0
mulsd  0xed7(%rip),%xmm0
movsd  %xmm0,(%rsi)
ret

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

LLVM IR (-O2):
define void @kernel(double* nocapture %0, double* nocapture writeonly %1, i32 %2) {
%4 = getelementptr inbounds double, double* %0, i64 1
%5 = load double, double* %4
%6 = getelementptr inbounds double, double* %0, i64 -1
%7 = load double, double* %6
%8 = sext i32 %2 to i64
%9 = getelementptr inbounds double, double* %0, i64 %8
%10 = load double, double* %9
%11 = sub nsw i64 0, %8
%12 = getelementptr inbounds double, double* %0, i64 %11
%13 = load double, double* %12
%14 = fadd double %5, %7
%15 = fadd double %14, %10
%16 = fadd double %15, %13
%17 = fmul double %16, 2.500000e-01
store double %17, double* %1
ret void
}