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