1; RUN: opt -S -loop-vectorize -mtriple=x86_64-apple-darwin %s | FileCheck %s 2 3; Two mostly identical functions. The only difference is the presence of 4; fast-math flags on the second. The loop is a pretty simple reduction: 5 6; for (int i = 0; i < 32; ++i) 7; if (arr[i] != 42) 8; tot += arr[i]; 9 10define double @sumIfScalar(double* nocapture readonly %arr) { 11; CHECK-LABEL: define double @sumIfScalar 12; CHECK-NOT: <2 x double> 13 14entry: 15 br label %loop 16 17loop: 18 %i = phi i32 [0, %entry], [%i.next, %next.iter] 19 %tot = phi double [0.0, %entry], [%tot.next, %next.iter] 20 21 %addr = getelementptr double, double* %arr, i32 %i 22 %nextval = load double, double* %addr 23 24 %tst = fcmp une double %nextval, 42.0 25 br i1 %tst, label %do.add, label %no.add 26 27do.add: 28 %tot.new = fadd double %tot, %nextval 29 br label %next.iter 30 31no.add: 32 br label %next.iter 33 34next.iter: 35 %tot.next = phi double [%tot, %no.add], [%tot.new, %do.add] 36 %i.next = add i32 %i, 1 37 %again = icmp ult i32 %i.next, 32 38 br i1 %again, label %loop, label %done 39 40done: 41 ret double %tot.next 42} 43 44define double @sumIfVector(double* nocapture readonly %arr) { 45; CHECK-LABEL: define double @sumIfVector 46; CHECK: <2 x double> 47entry: 48 br label %loop 49 50loop: 51 %i = phi i32 [0, %entry], [%i.next, %next.iter] 52 %tot = phi double [0.0, %entry], [%tot.next, %next.iter] 53 54 %addr = getelementptr double, double* %arr, i32 %i 55 %nextval = load double, double* %addr 56 57 %tst = fcmp fast une double %nextval, 42.0 58 br i1 %tst, label %do.add, label %no.add 59 60do.add: 61 %tot.new = fadd fast double %tot, %nextval 62 br label %next.iter 63 64no.add: 65 br label %next.iter 66 67next.iter: 68 %tot.next = phi double [%tot, %no.add], [%tot.new, %do.add] 69 %i.next = add i32 %i, 1 70 %again = icmp ult i32 %i.next, 32 71 br i1 %again, label %loop, label %done 72 73done: 74 ret double %tot.next 75} 76