xref: /llvm-project/llvm/test/Transforms/LoopStrengthReduce/callbr-critical-edge-splitting2.ll (revision 055fb7795aa219a3d274d280ec9129784f169f56)
1; RUN: opt -passes='loop(loop-reduce)' %s -o - -S | FileCheck %s
2
3; Required metadata to trigger previously failing assertion.
4target datalayout = "e-m:e-i64:64-n32:64"
5
6@f = external dso_local local_unnamed_addr global i32, align 4
7
8declare i32 @a() local_unnamed_addr
9declare i32 @e(i32) local_unnamed_addr
10
11define dso_local i32 @b() {
12entry:
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
16
17if.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]
24
25cleanup.cont.critedge:                            ; preds = %entry, %if.then
26  br label %return
27
28return:                                           ; preds = %if.then, %cleanup.cont.critedge
29  %retval.0 = phi i32 [ 4, %cleanup.cont.critedge ], [ 0, %if.then ]
30  ret i32 %retval.0
31}
32
33define dso_local i32 @do_pages_move_nr_pages() local_unnamed_addr {
34entry:
35  br label %for.cond
36
37for.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
42
43if.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
47
48if.then.i:                                        ; preds = %if.then
49  callbr void asm sideeffect "", "!i"()
50          to label %if.end3 [label %if.then2]
51
52if.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)
55  ret i32 undef
56
57if.end3:                                          ; preds = %for.cond, %if.then.i
58  %inc = add nsw i32 %g.0, 1
59  br label %for.cond
60}
61
62