1 ; RUN: opt < %s -passes=loop-vectorize,dce,instcombine -force-vector-interleave=1 -force-vector-width=4 -S | FileCheck %s
3 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
7 ;CHECK: mul nsw <4 x i32>
8 ;CHECK: store <4 x i32>
10 define i32 @flags1(i32 %n, ptr nocapture %A) nounwind uwtable ssp {
11 %1 = icmp sgt i32 %n, 9
12 br i1 %1, label %.lr.ph, label %._crit_edge
14 .lr.ph: ; preds = %0, %.lr.ph
15 %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 9, %0 ]
16 %2 = getelementptr inbounds i32, ptr %A, i64 %indvars.iv
17 %3 = load i32, ptr %2, align 4
18 %4 = mul nsw i32 %3, 3
19 store i32 %4, ptr %2, align 4
20 %indvars.iv.next = add i64 %indvars.iv, 1
21 %lftr.wideiv = trunc i64 %indvars.iv.next to i32
22 %exitcond = icmp eq i32 %lftr.wideiv, %n
23 br i1 %exitcond, label %._crit_edge, label %.lr.ph
25 ._crit_edge: ; preds = %.lr.ph, %0
30 ;CHECK-LABEL: @flags2(
31 ;CHECK: load <4 x i32>
33 ;CHECK: store <4 x i32>
35 define i32 @flags2(i32 %n, ptr nocapture %A) nounwind uwtable ssp {
36 %1 = icmp sgt i32 %n, 9
37 br i1 %1, label %.lr.ph, label %._crit_edge
39 .lr.ph: ; preds = %0, %.lr.ph
40 %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 9, %0 ]
41 %2 = getelementptr inbounds i32, ptr %A, i64 %indvars.iv
42 %3 = load i32, ptr %2, align 4
44 store i32 %4, ptr %2, align 4
45 %indvars.iv.next = add i64 %indvars.iv, 1
46 %lftr.wideiv = trunc i64 %indvars.iv.next to i32
47 %exitcond = icmp eq i32 %lftr.wideiv, %n
48 br i1 %exitcond, label %._crit_edge, label %.lr.ph
50 ._crit_edge: ; preds = %.lr.ph, %0
54 ; Make sure we copy fast math flags and use them for the final reduction.
55 ; CHECK-LABEL: fast_math
56 ; CHECK: load <4 x float>
57 ; CHECK: fadd fast <4 x float>
59 ; CHECK: call fast float @llvm.vector.reduce.fadd.v4f32
60 define float @fast_math(ptr noalias %s) {
65 %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
66 %q.04 = phi float [ 0.000000e+00, %entry ], [ %add, %for.body ]
67 %arrayidx = getelementptr inbounds float, ptr %s, i64 %indvars.iv
68 %0 = load float, ptr %arrayidx, align 4
69 %add = fadd fast float %q.04, %0
70 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
71 %exitcond = icmp eq i64 %indvars.iv.next, 256
72 br i1 %exitcond, label %for.end, label %for.body
75 %add.lcssa = phi float [ %add, %for.body ]