void signal_conv1d_double(double *y, double *x, double *k, const long yn,
                          const long kn, long stride) {
  long yi, ki;
  for (yi = 0; yi < yn; ++yi) {
    double *xi = x + yi * stride;
    for (ki = 0; ki < kn; ++ki)
      y[yi] += xi[ki] * k[ki];
  }
}


x86 assembly (clang, -O0):
<signal_conv1d_double>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%rax
cmp    -0x20(%rbp),%rax
jge    11bb <signal_conv1d_double+0xbb>
mov    -0x10(%rbp),%rax
mov    -0x38(%rbp),%rcx
imul   -0x30(%rbp),%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x48(%rbp)
movq   $0x0,-0x40(%rbp)
mov    -0x40(%rbp),%rax
cmp    -0x28(%rbp),%rax
jge    11a5 <signal_conv1d_double+0xa5>
mov    -0x48(%rbp),%rax
mov    -0x40(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
mov    -0x40(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
mov    -0x8(%rbp),%rax
mov    -0x38(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x40(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x40(%rbp)
jmp    1152 <signal_conv1d_double+0x52>
jmp    11aa <signal_conv1d_double+0xaa>
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    1124 <signal_conv1d_double+0x24>
pop    %rbp
ret

x86 assembly (clang, -O2):
<signal_conv1d_double>:
push   %r15
push   %r14
push   %rbx
test   %rcx,%rcx
jle    11ac <signal_conv1d_double+0xac>
mov    %r8,%r10
and    $0xfffffffffffffffe,%r10
lea    0x8(%rsi),%r14
lea    0x0(,%r9,8),%r11
xor    %r15d,%r15d
jmp    113c <signal_conv1d_double+0x3c>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%r15
add    %r11,%r14
cmp    %rcx,%r15
je     11ac <signal_conv1d_double+0xac>
test   %r8,%r8
jle    1130 <signal_conv1d_double+0x30>
movsd  (%rdi,%r15,8),%xmm0
xor    %eax,%eax
cmp    $0x1,%r8
je     1185 <signal_conv1d_double+0x85>
nop
movsd  -0x8(%r14,%rax,8),%xmm1
mulsd  (%rdx,%rax,8),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%rdi,%r15,8)
movsd  (%r14,%rax,8),%xmm0
mulsd  0x8(%rdx,%rax,8),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rdi,%r15,8)
add    $0x2,%rax
cmp    %rax,%r10
jne    1150 <signal_conv1d_double+0x50>
test   $0x1,%r8b
je     1130 <signal_conv1d_double+0x30>
mov    %r15,%rbx
imul   %r9,%rbx
lea    (%rsi,%rbx,8),%rbx
movsd  (%rbx,%rax,8),%xmm1
mulsd  (%rdx,%rax,8),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%rdi,%r15,8)
jmp    1130 <signal_conv1d_double+0x30>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @signal_conv1d_double(double* %0, double* %1, double* %2, i64 %3, i64 %4, i64 %5) {
%7 = alloca double*
%8 = alloca double*
%9 = alloca double*
%10 = alloca i64
%11 = alloca i64
%12 = alloca i64
%13 = alloca i64
%14 = alloca i64
%15 = alloca double*
store double* %0, double** %7
store double* %1, double** %8
store double* %2, double** %9
store i64 %3, i64* %10
store i64 %4, i64* %11
store i64 %5, i64* %12
store i64 0, i64* %13
br label %16
16: ; preds = %48, %6
%17 = load i64, i64* %13
%18 = load i64, i64* %10
%19 = icmp slt i64 %17, %18
br i1 %19, label %20, label %51
20: ; preds = %16
%21 = load double*, double** %8
%22 = load i64, i64* %13
%23 = load i64, i64* %12
%24 = mul nsw i64 %22, %23
%25 = getelementptr inbounds double, double* %21, i64 %24
store double* %25, double** %15
store i64 0, i64* %14
br label %26
26: ; preds = %44, %20
%27 = load i64, i64* %14
%28 = load i64, i64* %11
%29 = icmp slt i64 %27, %28
br i1 %29, label %30, label %47
30: ; preds = %26
%31 = load double*, double** %15
%32 = load i64, i64* %14
%33 = getelementptr inbounds double, double* %31, i64 %32
%34 = load double, double* %33
%35 = load double*, double** %9
%36 = load i64, i64* %14
%37 = getelementptr inbounds double, double* %35, i64 %36
%38 = load double, double* %37
%39 = load double*, double** %7
%40 = load i64, i64* %13
%41 = getelementptr inbounds double, double* %39, i64 %40
%42 = load double, double* %41
%43 = call double @llvm.fmuladd.f64(double %34, double %38, double %42)
store double %43, double* %41
br label %44
44: ; preds = %30
%45 = load i64, i64* %14
%46 = add nsw i64 %45, 1
store i64 %46, i64* %14
br label %26
47: ; preds = %26
br label %48
48: ; preds = %47
%49 = load i64, i64* %13
%50 = add nsw i64 %49, 1
store i64 %50, i64* %13
br label %16
51: ; preds = %16
ret void
}

LLVM IR (-O2):
define void @signal_conv1d_double(double* nocapture %0, double* nocapture %1, double* nocapture %2, i64 %3, i64 %4, i64 %5) {
%7 = icmp sgt i64 %3, 0
br i1 %7, label %8, label %51
8: ; preds = %6
%9 = icmp sgt i64 %4, 0
%10 = and i64 %4, 1
%11 = icmp eq i64 %4, 1
%12 = and i64 %4, -2
%13 = icmp eq i64 %10, 0
br label %14
14: ; preds = %8, %48
%15 = phi i64 [ 0, %8 ], [ %49, %48 ]
%16 = mul nsw i64 %15, %5
%17 = getelementptr inbounds double, double* %1, i64 %16
br i1 %9, label %18, label %48
18: ; preds = %14
%19 = getelementptr inbounds double, double* %0, i64 %15
%20 = load double, double* %19
br i1 %11, label %39, label %21
21: ; preds = %18, %21
%22 = phi double [ %35, %21 ], [ %20, %18 ]
%23 = phi i64 [ %36, %21 ], [ 0, %18 ]
%24 = phi i64 [ %37, %21 ], [ 0, %18 ]
%25 = getelementptr inbounds double, double* %17, i64 %23
%26 = load double, double* %25
%27 = getelementptr inbounds double, double* %2, i64 %23
%28 = load double, double* %27
%29 = tail call double @llvm.fmuladd.f64(double %26, double %28, double %22)
store double %29, double* %19
%30 = or i64 %23, 1
%31 = getelementptr inbounds double, double* %17, i64 %30
%32 = load double, double* %31
%33 = getelementptr inbounds double, double* %2, i64 %30
%34 = load double, double* %33
%35 = tail call double @llvm.fmuladd.f64(double %32, double %34, double %29)
store double %35, double* %19
%36 = add nuw nsw i64 %23, 2
%37 = add i64 %24, 2
%38 = icmp eq i64 %37, %12
br i1 %38, label %39, label %21
39: ; preds = %21, %18
%40 = phi double [ %20, %18 ], [ %35, %21 ]
%41 = phi i64 [ 0, %18 ], [ %36, %21 ]
br i1 %13, label %48, label %42
42: ; preds = %39
%43 = getelementptr inbounds double, double* %17, i64 %41
%44 = load double, double* %43
%45 = getelementptr inbounds double, double* %2, i64 %41
%46 = load double, double* %45
%47 = tail call double @llvm.fmuladd.f64(double %44, double %46, double %40)
store double %47, double* %19
br label %48
48: ; preds = %42, %39, %14
%49 = add nuw nsw i64 %15, 1
%50 = icmp eq i64 %49, %3
br i1 %50, label %51, label %14
51: ; preds = %48, %6
ret void
}