InstCombine: Remove infinite loop caused by FoldOpIntoPhi
[oota-llvm.git] / test / Transforms / InstCombine / fold-phi.ll
1 ; RUN: opt < %s -instcombine -S | FileCheck %s
2
3 ; CHECK: no_crash
4 define float @no_crash(float %a) nounwind {
5 entry:
6   br label %for.body
7
8 for.body:
9   %sum.057 = phi float [ 0.000000e+00, %entry ], [ %add5, %bb0 ]
10   %add5 = fadd float %sum.057, %a    ; PR14592
11   br i1 undef, label %bb0, label %end
12
13 bb0:
14   br label %for.body
15
16 end:
17   ret float %add5
18 }
19
20 ; CHECK-LABEL: @pr21377(
21 define void @pr21377(i32, i32) {
22 entry:
23   br label %while.cond.i
24
25 while.cond.i:                                     ; preds = %while.end.i, %entry
26   %g.0.i = phi i64 [ 0, %entry ], [ %phitmp5.i, %while.end.i ]
27   br i1 undef, label %fn2.exit, label %while.body.i
28
29 while.body.i:                                     ; preds = %while.cond.i
30   %conv.i = zext i32 %0 to i64
31   %phitmp3.i = or i64 %g.0.i, %conv.i
32   br label %while.cond3.i
33
34 while.cond3.i:                                    ; preds = %while.cond3.i, %while.body.i
35   %g.1.i = phi i64 [ %phitmp3.i, %while.body.i ], [ 0, %while.cond3.i ]
36   br i1 undef, label %while.end.i, label %while.cond3.i
37
38 while.end.i:                                      ; preds = %while.cond3.i
39   %conv.i.i = zext i32 %1 to i64
40   %or7.i = or i64 %g.1.i, %conv.i.i
41   %phitmp5.i = and i64 %or7.i, 4294967295
42   br label %while.cond.i
43
44 fn2.exit:                                         ; preds = %while.cond.i
45   ret void
46 }