• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt < %s -basicaa -slp-vectorizer -dce -S -mtriple=i386-apple-macosx10.8.0 -mcpu=corei7-avx | FileCheck %s
2
3target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128-n8:16:32-S128"
4target triple = "i386-apple-macosx10.8.0"
5
6; int foo(double *A, int n, int m) {
7;   double sum = 0, v1 = 2, v0 = 3;
8;   for (int i=0; i < n; ++i)
9;     sum += 7*A[i*2] + 7*A[i*2+1];
10;   return sum;
11; }
12
13;CHECK: reduce
14;CHECK: load <2 x double>
15;CHECK: fmul <2 x double>
16;CHECK: ret
17define i32 @reduce(double* nocapture %A, i32 %n, i32 %m) {
18entry:
19  %cmp13 = icmp sgt i32 %n, 0
20  br i1 %cmp13, label %for.body, label %for.end
21
22for.body:                                         ; preds = %entry, %for.body
23  %i.015 = phi i32 [ %inc, %for.body ], [ 0, %entry ]
24  %sum.014 = phi double [ %add6, %for.body ], [ 0.000000e+00, %entry ]
25  %mul = shl nsw i32 %i.015, 1
26  %arrayidx = getelementptr inbounds double, double* %A, i32 %mul
27  %0 = load double, double* %arrayidx, align 4
28  %mul1 = fmul double %0, 7.000000e+00
29  %add12 = or i32 %mul, 1
30  %arrayidx3 = getelementptr inbounds double, double* %A, i32 %add12
31  %1 = load double, double* %arrayidx3, align 4
32  %mul4 = fmul double %1, 7.000000e+00
33  %add5 = fadd double %mul1, %mul4
34  %add6 = fadd double %sum.014, %add5
35  %inc = add nsw i32 %i.015, 1
36  %exitcond = icmp eq i32 %inc, %n
37  br i1 %exitcond, label %for.cond.for.end_crit_edge, label %for.body
38
39for.cond.for.end_crit_edge:                       ; preds = %for.body
40  %phitmp = fptosi double %add6 to i32
41  br label %for.end
42
43for.end:                                          ; preds = %for.cond.for.end_crit_edge, %entry
44  %sum.0.lcssa = phi i32 [ %phitmp, %for.cond.for.end_crit_edge ], [ 0, %entry ]
45  ret i32 %sum.0.lcssa
46}
47
48