1 ; RUN: opt -passes='loop(loop-reduce)' %s -o - -S | FileCheck %s
3 ; Required metadata to trigger previously failing assertion.
4 target datalayout = "e-m:e-i64:64-n32:64"
6 @f = external dso_local local_unnamed_addr global i32, align 4
8 declare i32 @a() local_unnamed_addr
9 declare i32 @e(i32) local_unnamed_addr
11 define dso_local i32 @b() {
13 %call = tail call i32 @a()
14 %tobool.not = icmp eq i32 %call, 0
15 br i1 %tobool.not, label %cleanup.cont.critedge, label %if.then
17 if.then: ; preds = %entry
18 ; It's ok to modify this test in the future should be able to split critical
19 ; edges here, just noting that this is the critical edge that we care about.
20 ; CHECK: callbr void asm sideeffect "", "!i"()
21 ; CHECK-NEXT: to label %return [label %cleanup.cont.critedge]
22 callbr void asm sideeffect "", "!i"()
23 to label %return [label %cleanup.cont.critedge]
25 cleanup.cont.critedge: ; preds = %entry, %if.then
28 return: ; preds = %if.then, %cleanup.cont.critedge
29 %retval.0 = phi i32 [ 4, %cleanup.cont.critedge ], [ 0, %if.then ]
33 define dso_local i32 @do_pages_move_nr_pages() local_unnamed_addr {
37 for.cond: ; preds = %if.end3, %entry
38 %g.0 = phi i32 [ undef, %entry ], [ %inc, %if.end3 ]
39 %0 = load i32, ptr @f, align 4
40 %tobool.not = icmp eq i32 %0, 0
41 br i1 %tobool.not, label %if.end3, label %if.then
43 if.then: ; preds = %for.cond
44 %call.i = tail call i32 @a()
45 %tobool.not.i = icmp eq i32 %call.i, 0
46 br i1 %tobool.not.i, label %if.then2, label %if.then.i
48 if.then.i: ; preds = %if.then
49 callbr void asm sideeffect "", "!i"()
50 to label %if.end3 [label %if.then2]
52 if.then2: ; preds = %if.then, %if.then.i
53 %g.0.lcssa = phi i32 [ %g.0, %if.then ], [ %g.0, %if.then.i ]
54 %call4 = tail call i32 @e(i32 %g.0.lcssa)
57 if.end3: ; preds = %for.cond, %if.then.i
58 %inc = add nsw i32 %g.0, 1