1 ; RUN: opt -loop-rotate -enable-new-pm=0 -print-memoryssa -disable-output -verify-memoryssa %s 2>&1 | FileCheck %s
2 ; RUN: opt -passes='loop-mssa(loop-rotate),print<memoryssa>' -disable-output -verify-memoryssa %s 2>&1 | FileCheck %s
5 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
6 target triple = "x86_64-grtev4-linux-gnu"
8 declare double @sqrt(double)
11 define internal fastcc double @f(i32* %n_, double* %dx) align 32 {
14 ; CHECK: MemoryUse(liveOnEntry)
15 ; CHECK-NOT: 7 = MemoryPhi
16 ; CHECK-NOT: 6 = MemoryPhi
17 %v0 = load i32, i32* %n_, align 4
20 for.cond: ; preds = %for.body, %entry
21 %xmax.0 = phi double [ undef, %entry ], [ %xmax.1, %for.body ]
22 %i.0 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
23 %cmp = icmp slt i32 %i.0, %v0
24 br i1 %cmp, label %for.body, label %for.end
26 for.body: ; preds = %for.cond
27 %idxprom = zext i32 %i.0 to i64
28 %arrayidx = getelementptr inbounds double, double* %dx, i64 %idxprom
29 %v1 = load double, double* %arrayidx, align 8
30 %cmp1 = fcmp ueq double %v1, 0.000000e+00
31 %xmax.1 = select i1 %cmp1, double %xmax.0, double %v1
32 %inc = add nuw nsw i32 %i.0, 1
35 for.end: ; preds = %for.cond
36 %xmax.0.lcssa = phi double [ %xmax.0, %for.cond ]
37 %cmp2 = fcmp oeq double %xmax.0.lcssa, 0.000000e+00
38 br i1 %cmp2, label %cleanup, label %if.end4
40 if.end4: ; preds = %for.end
41 %div = fdiv double 1.000000e+00, %xmax.0.lcssa
42 %cmp61 = icmp slt i32 0, %v0
43 br i1 %cmp61, label %for.body7.lr.ph, label %for.end15
45 for.body7.lr.ph: ; preds = %if.end4
49 ; CHECK: 3 = MemoryPhi({for.body7.lr.ph,liveOnEntry},{for.body7,1})
50 for.body7: ; preds = %for.body7.lr.ph, %for.body7
51 %i.13 = phi i32 [ 0, %for.body7.lr.ph ], [ %inc14, %for.body7 ]
52 %sum.02 = phi x86_fp80 [ undef, %for.body7.lr.ph ], [ %add, %for.body7 ]
53 %idxprom9 = zext i32 %i.13 to i64
54 %arrayidx10 = getelementptr inbounds double, double* %dx, i64 %idxprom9
55 %v3 = load double, double* %arrayidx10, align 8
56 %mul11 = fmul double %div, %v3
57 %v2 = call double @sqrt(double %v3)
58 %mul12 = fmul double %mul11, %v2
59 %conv = fpext double %mul12 to x86_fp80
60 %add = fadd x86_fp80 %sum.02, %conv
61 %inc14 = add nuw nsw i32 %i.13, 1
62 %cmp6 = icmp slt i32 %inc14, %v0
63 br i1 %cmp6, label %for.body7, label %for.cond5.for.end15_crit_edge
65 for.cond5.for.end15_crit_edge: ; preds = %for.body7
66 %split = phi x86_fp80 [ %add, %for.body7 ]
69 for.end15: ; preds = %for.cond5.for.end15_crit_edge, %if.end4
70 %sum.0.lcssa = phi x86_fp80 [ %split, %for.cond5.for.end15_crit_edge ], [ undef, %if.end4 ]
71 %conv16 = fptrunc x86_fp80 %sum.0.lcssa to double
72 %call = call double @sqrt(double %conv16)
73 %mul17 = fmul double %call, 0.000000e+00
76 cleanup: ; preds = %for.end15, %for.end
77 %retval.0 = phi double [ undef, %for.end ], [ %mul17, %for.end15 ]