void test_double_2(double *restrict x, double *restrict pred, int n) {
  for (int i = 0; i < n; ++i)
    x[i] = pred[i] > 0 ? 2.0 : pred[i];
}


x86 assembly (clang, -O0):
<test_double_2>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1180 <test_double_2+0x80>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    114e <test_double_2+0x4e>
movsd  0xebc(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    1160 <test_double_2+0x60>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1116 <test_double_2+0x16>
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_double_2>:
test   %edx,%edx
jle    127c <test_double_2+0x17c>
mov    %edx,%r9d
cmp    $0x4,%edx
jae    1117 <test_double_2+0x17>
xor    %ecx,%ecx
jmp    1247 <test_double_2+0x147>
mov    %r9d,%ecx
and    $0xfffffffc,%ecx
lea    -0x4(%rcx),%rax
mov    %rax,%r8
shr    $0x2,%r8
add    $0x1,%r8
test   %rax,%rax
je     127d <test_double_2+0x17d>
mov    %r8,%rax
and    $0xfffffffffffffffe,%rax
xor    %edx,%edx
movapd 0xeba(%rip),%xmm0
cs nopw 0x0(%rax,%rax,1)
movupd (%rsi,%rdx,8),%xmm1
movupd 0x10(%rsi,%rdx,8),%xmm2
xorpd  %xmm3,%xmm3
cmpltpd %xmm1,%xmm3
xorpd  %xmm4,%xmm4
cmpltpd %xmm2,%xmm4
movapd %xmm0,%xmm5
andpd  %xmm3,%xmm5
andnpd %xmm1,%xmm3
orpd   %xmm5,%xmm3
movapd %xmm0,%xmm1
andpd  %xmm4,%xmm1
andnpd %xmm2,%xmm4
orpd   %xmm1,%xmm4
movupd %xmm3,(%rdi,%rdx,8)
movupd %xmm4,0x10(%rdi,%rdx,8)
movupd 0x20(%rsi,%rdx,8),%xmm1
movupd 0x30(%rsi,%rdx,8),%xmm2
xorpd  %xmm3,%xmm3
cmpltpd %xmm1,%xmm3
xorpd  %xmm4,%xmm4
cmpltpd %xmm2,%xmm4
movapd %xmm0,%xmm5
andpd  %xmm3,%xmm5
andnpd %xmm1,%xmm3
orpd   %xmm5,%xmm3
movapd %xmm0,%xmm1
andpd  %xmm4,%xmm1
andnpd %xmm2,%xmm4
orpd   %xmm1,%xmm4
movupd %xmm3,0x20(%rdi,%rdx,8)
movupd %xmm4,0x30(%rdi,%rdx,8)
add    $0x8,%rdx
add    $0xfffffffffffffffe,%rax
jne    1150 <test_double_2+0x50>
test   $0x1,%r8b
je     1242 <test_double_2+0x142>
movupd (%rsi,%rdx,8),%xmm0
movupd 0x10(%rsi,%rdx,8),%xmm1
xorpd  %xmm2,%xmm2
xorpd  %xmm3,%xmm3
cmpltpd %xmm0,%xmm3
cmpltpd %xmm1,%xmm2
movapd 0xde5(%rip),%xmm4
movapd %xmm4,%xmm5
andpd  %xmm3,%xmm5
andnpd %xmm0,%xmm3
orpd   %xmm5,%xmm3
andpd  %xmm2,%xmm4
andnpd %xmm1,%xmm2
orpd   %xmm4,%xmm2
movupd %xmm3,(%rdi,%rdx,8)
movupd %xmm2,0x10(%rdi,%rdx,8)
cmp    %r9,%rcx
je     127c <test_double_2+0x17c>
movsd  0xdc1(%rip),%xmm0
nop
movsd  (%rsi,%rcx,8),%xmm1
xorpd  %xmm2,%xmm2
cmpltsd %xmm1,%xmm2
movapd %xmm2,%xmm3
andnpd %xmm1,%xmm3
andpd  %xmm0,%xmm2
orpd   %xmm3,%xmm2
movlpd %xmm2,(%rdi,%rcx,8)
add    $0x1,%rcx
cmp    %rcx,%r9
jne    1250 <test_double_2+0x150>
ret
xor    %edx,%edx
test   $0x1,%r8b
jne    11f6 <test_double_2+0xf6>
jmp    1242 <test_double_2+0x142>

LLVM IR (-O0):
define void @test_double_2(double* noalias %0, double* noalias %1, i32 %2) {
%4 = alloca double*
%5 = alloca double*
%6 = alloca i32
%7 = alloca i32
store double* %0, double** %4
store double* %1, double** %5
store i32 %2, i32* %6
store i32 0, i32* %7
br label %8
8: ; preds = %32, %3
%9 = load i32, i32* %7
%10 = load i32, i32* %6
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %35
12: ; preds = %8
%13 = load double*, double** %5
%14 = load i32, i32* %7
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds double, double* %13, i64 %15
%17 = load double, double* %16
%18 = fcmp ogt double %17, 0.000000e+00
br i1 %18, label %19, label %20
19: ; preds = %12
br label %26
20: ; preds = %12
%21 = load double*, double** %5
%22 = load i32, i32* %7
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds double, double* %21, i64 %23
%25 = load double, double* %24
br label %26
26: ; preds = %20, %19
%27 = phi double [ 2.000000e+00, %19 ], [ %25, %20 ]
%28 = load double*, double** %4
%29 = load i32, i32* %7
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds double, double* %28, i64 %30
store double %27, double* %31
br label %32
32: ; preds = %26
%33 = load i32, i32* %7
%34 = add nsw i32 %33, 1
store i32 %34, i32* %7
br label %8
35: ; preds = %8
ret void
}

LLVM IR (-O2):
define void @test_double_2(double* noalias nocapture writeonly %0, double* noalias nocapture %1, i32 %2) {
%4 = icmp sgt i32 %2, 0
br i1 %4, label %5, label %74
5: ; preds = %3
%6 = zext i32 %2 to i64
%7 = icmp ult i32 %2, 4
br i1 %7, label %72, label %8
8: ; preds = %5
%9 = and i64 %6, 4294967292
%10 = add nsw i64 %9, -4
%11 = lshr exact i64 %10, 2
%12 = add nuw nsw i64 %11, 1
%13 = and i64 %12, 1
%14 = icmp eq i64 %10, 0
br i1 %14, label %52, label %15
15: ; preds = %8
%16 = and i64 %12, 9223372036854775806
br label %17
17: ; preds = %17, %15
%18 = phi i64 [ 0, %15 ], [ %49, %17 ]
%19 = phi i64 [ 0, %15 ], [ %50, %17 ]
%20 = getelementptr inbounds double, double* %1, i64 %18
%21 = bitcast double* %20 to <2 x double>*
%22 = load <2 x double>, <2 x double>* %21
%23 = getelementptr inbounds double, double* %20, i64 2
%24 = bitcast double* %23 to <2 x double>*
%25 = load <2 x double>, <2 x double>* %24
%26 = fcmp ogt <2 x double> %22, zeroinitializer
%27 = fcmp ogt <2 x double> %25, zeroinitializer
%28 = select <2 x i1> %26, <2 x double> <double 2.000000e+00, double 2.000000e+00>, <2 x double> %22
%29 = select <2 x i1> %27, <2 x double> <double 2.000000e+00, double 2.000000e+00>, <2 x double> %25
%30 = getelementptr inbounds double, double* %0, i64 %18
%31 = bitcast double* %30 to <2 x double>*
store <2 x double> %28, <2 x double>* %31
%32 = getelementptr inbounds double, double* %30, i64 2
%33 = bitcast double* %32 to <2 x double>*
store <2 x double> %29, <2 x double>* %33
%34 = or i64 %18, 4
%35 = getelementptr inbounds double, double* %1, i64 %34
%36 = bitcast double* %35 to <2 x double>*
%37 = load <2 x double>, <2 x double>* %36
%38 = getelementptr inbounds double, double* %35, i64 2
%39 = bitcast double* %38 to <2 x double>*
%40 = load <2 x double>, <2 x double>* %39
%41 = fcmp ogt <2 x double> %37, zeroinitializer
%42 = fcmp ogt <2 x double> %40, zeroinitializer
%43 = select <2 x i1> %41, <2 x double> <double 2.000000e+00, double 2.000000e+00>, <2 x double> %37
%44 = select <2 x i1> %42, <2 x double> <double 2.000000e+00, double 2.000000e+00>, <2 x double> %40
%45 = getelementptr inbounds double, double* %0, i64 %34
%46 = bitcast double* %45 to <2 x double>*
store <2 x double> %43, <2 x double>* %46
%47 = getelementptr inbounds double, double* %45, i64 2
%48 = bitcast double* %47 to <2 x double>*
store <2 x double> %44, <2 x double>* %48
%49 = add nuw i64 %18, 8
%50 = add i64 %19, 2
%51 = icmp eq i64 %50, %16
br i1 %51, label %52, label %17
52: ; preds = %17, %8
%53 = phi i64 [ 0, %8 ], [ %49, %17 ]
%54 = icmp eq i64 %13, 0
br i1 %54, label %70, label %55
55: ; preds = %52
%56 = getelementptr inbounds double, double* %1, i64 %53
%57 = bitcast double* %56 to <2 x double>*
%58 = load <2 x double>, <2 x double>* %57
%59 = getelementptr inbounds double, double* %56, i64 2
%60 = bitcast double* %59 to <2 x double>*
%61 = load <2 x double>, <2 x double>* %60
%62 = fcmp ogt <2 x double> %58, zeroinitializer
%63 = fcmp ogt <2 x double> %61, zeroinitializer
%64 = select <2 x i1> %62, <2 x double> <double 2.000000e+00, double 2.000000e+00>, <2 x double> %58
%65 = select <2 x i1> %63, <2 x double> <double 2.000000e+00, double 2.000000e+00>, <2 x double> %61
%66 = getelementptr inbounds double, double* %0, i64 %53
%67 = bitcast double* %66 to <2 x double>*
store <2 x double> %64, <2 x double>* %67
%68 = getelementptr inbounds double, double* %66, i64 2
%69 = bitcast double* %68 to <2 x double>*
store <2 x double> %65, <2 x double>* %69
br label %70
70: ; preds = %52, %55
%71 = icmp eq i64 %9, %6
br i1 %71, label %74, label %72
72: ; preds = %5, %70
%73 = phi i64 [ 0, %5 ], [ %9, %70 ]
br label %75
74: ; preds = %75, %70, %3
ret void
75: ; preds = %72, %75
%76 = phi i64 [ %82, %75 ], [ %73, %72 ]
%77 = getelementptr inbounds double, double* %1, i64 %76
%78 = load double, double* %77
%79 = fcmp ogt double %78, 0.000000e+00
%80 = select i1 %79, double 2.000000e+00, double %78
%81 = getelementptr inbounds double, double* %0, i64 %76
store double %80, double* %81
%82 = add nuw nsw i64 %76, 1
%83 = icmp eq i64 %82, %6
br i1 %83, label %74, label %75
}