blob: 6619c7d19d8a7d54dffab7a1ebe018efd2d9925e [file] [log] [blame]
Devang Patelb8935d52007-09-25 18:24:48 +00001; PR714
2; Update loop iteraton space to eliminate condition inside loop.
3; RUN: llvm-as < %s | opt -loop-index-split | llvm-dis | not grep bothcond
Devang Patel37c8ad92008-12-04 21:38:42 +00004
Devang Patelb8935d52007-09-25 18:24:48 +00005define void @test(float* %x, i32 %ndat, float** %y, float %xcen, i32 %xmin, i32 %xmax, float %sigmal, float %contribution) {
6entry:
7 %tmp5310 = icmp sgt i32 %xmin, %xmax ; <i1> [#uses=1]
8 br i1 %tmp5310, label %return, label %bb.preheader
9
10bb.preheader: ; preds = %entry
11 %tmp3031 = fpext float %contribution to double ; <double> [#uses=1]
Dan Gohman7ce405e2009-06-04 22:49:04 +000012 %tmp32 = fmul double %tmp3031, 5.000000e-01 ; <double> [#uses=1]
Devang Patelb8935d52007-09-25 18:24:48 +000013 %tmp3839 = fpext float %sigmal to double ; <double> [#uses=1]
14 br label %bb
15
Devang Patel37c8ad92008-12-04 21:38:42 +000016bb: ; preds = %cond_next45, %bb.preheader
17 %k.06.0 = phi i32 [ 0, %bb.preheader ], [ %indvar.next, %cond_next45 ] ; <i32> [#uses=4]
18 %i.01.0 = add i32 %k.06.0, %xmin ; <i32> [#uses=4]
Devang Patelb8935d52007-09-25 18:24:48 +000019 %tmp2 = icmp sgt i32 %i.01.0, -1 ; <i1> [#uses=1]
20 %tmp6 = icmp slt i32 %i.01.0, %ndat ; <i1> [#uses=1]
21 %bothcond = and i1 %tmp2, %tmp6 ; <i1> [#uses=1]
22 br i1 %bothcond, label %cond_true9, label %cond_next45
23
24cond_true9: ; preds = %bb
25 %tmp12 = getelementptr float* %x, i32 %i.01.0 ; <float*> [#uses=1]
26 %tmp13 = load float* %tmp12, align 4 ; <float> [#uses=1]
Dan Gohman7ce405e2009-06-04 22:49:04 +000027 %tmp15 = fsub float %xcen, %tmp13 ; <float> [#uses=1]
Devang Patel37c8ad92008-12-04 21:38:42 +000028 %tmp16 = tail call float @fabsf(float %tmp15) ; <float> [#uses=1]
Devang Patelb8935d52007-09-25 18:24:48 +000029 %tmp18 = fdiv float %tmp16, %sigmal ; <float> [#uses=1]
30 %tmp21 = load float** %y, align 4 ; <float*> [#uses=2]
31 %tmp27 = getelementptr float* %tmp21, i32 %k.06.0 ; <float*> [#uses=1]
32 %tmp28 = load float* %tmp27, align 4 ; <float> [#uses=1]
33 %tmp2829 = fpext float %tmp28 to double ; <double> [#uses=1]
Dan Gohman7ce405e2009-06-04 22:49:04 +000034 %tmp34 = fsub float -0.000000e+00, %tmp18 ; <float> [#uses=1]
Devang Patelb8935d52007-09-25 18:24:48 +000035 %tmp3435 = fpext float %tmp34 to double ; <double> [#uses=1]
Devang Patel37c8ad92008-12-04 21:38:42 +000036 %tmp36 = tail call double @exp(double %tmp3435) ; <double> [#uses=1]
Dan Gohman7ce405e2009-06-04 22:49:04 +000037 %tmp37 = fmul double %tmp32, %tmp36 ; <double> [#uses=1]
Devang Patelb8935d52007-09-25 18:24:48 +000038 %tmp40 = fdiv double %tmp37, %tmp3839 ; <double> [#uses=1]
Dan Gohman7ce405e2009-06-04 22:49:04 +000039 %tmp41 = fadd double %tmp2829, %tmp40 ; <double> [#uses=1]
Devang Patelb8935d52007-09-25 18:24:48 +000040 %tmp4142 = fptrunc double %tmp41 to float ; <float> [#uses=1]
41 %tmp44 = getelementptr float* %tmp21, i32 %k.06.0 ; <float*> [#uses=1]
42 store float %tmp4142, float* %tmp44, align 4
43 br label %cond_next45
44
Devang Patel37c8ad92008-12-04 21:38:42 +000045cond_next45: ; preds = %cond_true9, %bb
46 %tmp47 = add i32 %i.01.0, 1 ; <i32> [#uses=1]
Devang Patelb8935d52007-09-25 18:24:48 +000047 %tmp53 = icmp sgt i32 %tmp47, %xmax ; <i1> [#uses=1]
Devang Patel37c8ad92008-12-04 21:38:42 +000048 %indvar.next = add i32 %k.06.0, 1 ; <i32> [#uses=1]
Devang Patelb8935d52007-09-25 18:24:48 +000049 br i1 %tmp53, label %return.loopexit, label %bb
50
51return.loopexit: ; preds = %cond_next45
52 br label %return
53
54return: ; preds = %return.loopexit, %entry
55 ret void
56}
57
58declare float @fabsf(float)
59
60declare double @exp(double)