1 ; RUN: opt < %s -loop-vectorize -force-vector-interleave=1 -force-vector-width=4 -dce -instcombine -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"
5 ;CHECK: fadd fast <4 x float>
7 define float @foo(float* nocapture %A, i32* nocapture %n) nounwind uwtable readonly ssp {
11 for.body: ; preds = %for.body, %entry
12 %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
13 %sum.04 = phi float [ 0.000000e+00, %entry ], [ %add, %for.body ]
14 %arrayidx = getelementptr inbounds float, float* %A, i64 %indvars.iv
15 %0 = load float, float* %arrayidx, align 4
16 %add = fadd fast float %sum.04, %0
17 %indvars.iv.next = add i64 %indvars.iv, 1
18 %lftr.wideiv = trunc i64 %indvars.iv.next to i32
19 %exitcond = icmp eq i32 %lftr.wideiv, 200
20 br i1 %exitcond, label %for.end, label %for.body
22 for.end: ; preds = %for.body
26 ;CHECK-LABEL: @foosub(
27 ;CHECK: fsub fast <4 x float>
29 define float @foosub(float* nocapture %A, i32* nocapture %n) nounwind uwtable readonly ssp {
33 for.body: ; preds = %for.body, %entry
34 %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
35 %sum.04 = phi float [ 0.000000e+00, %entry ], [ %sub, %for.body ]
36 %arrayidx = getelementptr inbounds float, float* %A, i64 %indvars.iv
37 %0 = load float, float* %arrayidx, align 4
38 %sub = fsub fast float %sum.04, %0
39 %indvars.iv.next = add i64 %indvars.iv, 1
40 %lftr.wideiv = trunc i64 %indvars.iv.next to i32
41 %exitcond = icmp eq i32 %lftr.wideiv, 200
42 br i1 %exitcond, label %for.end, label %for.body
44 for.end: ; preds = %for.body
48 ;CHECK-LABEL: @foodiv(
49 ;CHECK: fdiv fast <4 x float>
51 define float @foodiv(float* nocapture %A, i32* nocapture %n) nounwind uwtable readonly ssp {
55 for.body: ; preds = %for.body, %entry
56 %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
57 %sum.04 = phi float [ 1.000000e+00, %entry ], [ %sub, %for.body ]
58 %arrayidx = getelementptr inbounds float, float* %A, i64 %indvars.iv
59 %0 = load float, float* %arrayidx, align 4
60 %sub = fdiv fast float %sum.04, %0
61 %indvars.iv.next = add i64 %indvars.iv, 1
62 %lftr.wideiv = trunc i64 %indvars.iv.next to i32
63 %exitcond = icmp eq i32 %lftr.wideiv, 200
64 br i1 %exitcond, label %for.end, label %for.body
66 for.end: ; preds = %for.body
70 ;CHECK-LABEL: @foonodiv(
71 ;CHECK-NOT: fdiv fast <4 x float>
73 define float @foonodiv(float* nocapture %A, i32* nocapture %n) nounwind uwtable readonly ssp {
77 for.body: ; preds = %for.body, %entry
78 %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
79 %sum.04 = phi float [ 1.000000e+00, %entry ], [ %sub, %for.body ]
80 %arrayidx = getelementptr inbounds float, float* %A, i64 %indvars.iv
81 %0 = load float, float* %arrayidx, align 4
82 %sub = fdiv fast float %0, %sum.04
83 %indvars.iv.next = add i64 %indvars.iv, 1
84 %lftr.wideiv = trunc i64 %indvars.iv.next to i32
85 %exitcond = icmp eq i32 %lftr.wideiv, 200
86 br i1 %exitcond, label %for.end, label %for.body
88 for.end: ; preds = %for.body