1; The loop canonicalization pass should guarantee that there is one backedge
2; for all loops.  This allows the -indvars pass to recognize the %IV
3; induction variable in this testcase.
4
5; RUN: opt < %s -indvars -S | FileCheck %s
6; CHECK: Loop.backedge:
7; CHECK-NOT: br
8; CHECK: br label %Loop, !dbg [[BACKEDGE_LOC:![0-9]+]]
9
10; CHECK: [[BACKEDGE_LOC]] = !DILocation(line: 101, column: 1, scope: !{{.*}})
11
12define i32 @test(i1 %C) {
13; <label>:0
14  br label %Loop, !dbg !6
15Loop: ; preds = %BE2, %BE1, %0
16  %IV = phi i32 [ 1, %0 ], [ %IV2, %BE1 ], [ %IV2, %BE2 ] ; <i32> [#uses=2]
17  store i32 %IV, i32* null, !dbg !7
18  %IV2 = add i32 %IV, 2, !dbg !8 ; <i32> [#uses=2]
19  br i1 %C, label %BE1, label %BE2, !dbg !9
20BE1:  ; preds = %Loop
21  br label %Loop, !dbg !10
22BE2:    ; preds = %n br label %Loop
23  br label %Loop, !dbg !11
24}
25
26!llvm.module.flags = !{!0, !1}
27!0 = !{i32 2, !"Dwarf Version", i32 4}
28!1 = !{i32 2, !"Debug Info Version", i32 3}
29
30!2 = !{}
31!3 = !DISubroutineType(types: !2)
32!4 = !DIFile(filename: "atomic.cpp", directory: "/tmp")
33!5 = distinct !DISubprogram(name: "test", scope: !4, file: !4, line: 99, type: !3, isLocal: false, isDefinition: true, scopeLine: 100, flags: DIFlagPrototyped, isOptimized: false, variables: !2)
34!6 = !DILocation(line: 100, column: 1, scope: !5)
35!7 = !DILocation(line: 101, column: 1, scope: !5)
36!8 = !DILocation(line: 102, column: 1, scope: !5)
37!9 = !DILocation(line: 103, column: 1, scope: !5)
38!10 = !DILocation(line: 104, column: 1, scope: !5)
39!11 = !DILocation(line: 105, column: 1, scope: !5)
40