void __attribute__((noipa))
test_double_sub(double *__restrict r, double *__restrict a,
                double *__restrict b, double c, double *__restrict pred,
                int n) {
  for (int i = 0; i < n; ++i)
    r[i] = pred[i] != 1 ? a[i] - b[i] * c : b[i];
}


x86 assembly (clang, -O0):
<test_double_sub>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movsd  %xmm0,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8d,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jge    11d4 <test_double_sub+0xd4>
mov    -0x28(%rbp),%rax
movslq -0x30(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  0xebb(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    115a <test_double_sub+0x5a>
jp     115a <test_double_sub+0x5a>
jmp    11a2 <test_double_sub+0xa2>
mov    -0x10(%rbp),%rax
movslq -0x30(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x18(%rbp),%rax
movslq -0x30(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  -0x20(%rbp),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    11b4 <test_double_sub+0xb4>
mov    -0x18(%rbp),%rax
movslq -0x30(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x30(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1124 <test_double_sub+0x24>
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_double_sub>:
test   %r8d,%r8d
jle    1154 <test_double_sub+0x54>
mov    %r8d,%r8d
xor    %eax,%eax
movsd  0xeee(%rip),%xmm1
jmp    1133 <test_double_sub+0x33>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsd  (%rdx,%rax,8),%xmm2
movsd  %xmm2,(%rdi,%rax,8)
add    $0x1,%rax
cmp    %rax,%r8
je     1154 <test_double_sub+0x54>
movsd  (%rcx,%rax,8),%xmm2
ucomisd %xmm1,%xmm2
jne    1140 <test_double_sub+0x40>
jnp    1120 <test_double_sub+0x20>
movsd  (%rsi,%rax,8),%xmm2
movsd  (%rdx,%rax,8),%xmm3
mulsd  %xmm0,%xmm3
subsd  %xmm3,%xmm2
jmp    1125 <test_double_sub+0x25>
ret

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

LLVM IR (-O2):
define void @test_double_sub(double* noalias nocapture writeonly %0, double* noalias nocapture %1, double* noalias nocapture %2, double %3, double* noalias nocapture %4, i32 %5) {
%7 = icmp sgt i32 %5, 0
br i1 %7, label %8, label %10
8: ; preds = %6
%9 = zext i32 %5 to i64
br label %11
10: ; preds = %26, %6
ret void
11: ; preds = %8, %26
%12 = phi i64 [ 0, %8 ], [ %29, %26 ]
%13 = getelementptr inbounds double, double* %4, i64 %12
%14 = load double, double* %13
%15 = fcmp une double %14, 1.000000e+00
br i1 %15, label %16, label %23
16: ; preds = %11
%17 = getelementptr inbounds double, double* %1, i64 %12
%18 = load double, double* %17
%19 = getelementptr inbounds double, double* %2, i64 %12
%20 = load double, double* %19
%21 = fneg double %20
%22 = tail call double @llvm.fmuladd.f64(double %21, double %3, double %18)
br label %26
23: ; preds = %11
%24 = getelementptr inbounds double, double* %2, i64 %12
%25 = load double, double* %24
br label %26
26: ; preds = %23, %16
%27 = phi double [ %22, %16 ], [ %25, %23 ]
%28 = getelementptr inbounds double, double* %0, i64 %12
store double %27, double* %28
%29 = add nuw nsw i64 %12, 1
%30 = icmp eq i64 %29, %9
br i1 %30, label %10, label %11
}