|
| 1 | +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 4 |
| 2 | +; RUN: opt -mtriple=amdgcn-- -S -structurizecfg -si-annotate-control-flow %s | FileCheck -check-prefix=OPT %s |
| 3 | + |
| 4 | +define amdgpu_ps i32 @if_else(i32 %0) !dbg !5 { |
| 5 | +; OPT-LABEL: define amdgpu_ps i32 @if_else( |
| 6 | +; OPT-SAME: i32 [[TMP0:%.*]]) !dbg [[DBG5:![0-9]+]] { |
| 7 | +; OPT-NEXT: [[C:%.*]] = icmp ne i32 [[TMP0]], 0, !dbg [[DBG13:![0-9]+]] |
| 8 | +; OPT-NEXT: tail call void @llvm.dbg.value(metadata i1 [[C]], metadata [[META9:![0-9]+]], metadata !DIExpression()), !dbg [[DBG13]] |
| 9 | +; OPT-NEXT: [[TMP2:%.*]] = call { i1, i64 } @llvm.amdgcn.if.i64(i1 [[C]]) |
| 10 | +; OPT-NEXT: [[TMP3:%.*]] = extractvalue { i1, i64 } [[TMP2]], 0 |
| 11 | +; OPT-NEXT: [[TMP4:%.*]] = extractvalue { i1, i64 } [[TMP2]], 1 |
| 12 | +; OPT-NEXT: br i1 [[TMP3]], label [[FALSE:%.*]], label [[FLOW:%.*]], !dbg [[DBG14:![0-9]+]] |
| 13 | +; OPT: Flow: |
| 14 | +; OPT-NEXT: [[TMP5:%.*]] = phi i32 [ 33, [[FALSE]] ], [ undef, [[TMP1:%.*]] ] |
| 15 | +; OPT-NEXT: [[TMP6:%.*]] = call { i1, i64 } @llvm.amdgcn.else.i64.i64(i64 [[TMP4]]) |
| 16 | +; OPT-NEXT: [[TMP7:%.*]] = extractvalue { i1, i64 } [[TMP6]], 0 |
| 17 | +; OPT-NEXT: [[TMP8:%.*]] = extractvalue { i1, i64 } [[TMP6]], 1 |
| 18 | +; OPT-NEXT: br i1 [[TMP7]], label [[TRUE:%.*]], label [[EXIT:%.*]], !dbg [[DBG14]] |
| 19 | +; OPT: true: |
| 20 | +; OPT-NEXT: br label [[EXIT]], !dbg [[DBG15:![0-9]+]] |
| 21 | +; OPT: false: |
| 22 | +; OPT-NEXT: br label [[FLOW]], !dbg [[DBG16:![0-9]+]] |
| 23 | +; OPT: exit: |
| 24 | +; OPT-NEXT: [[RET:%.*]] = phi i32 [ [[TMP5]], [[FLOW]] ], [ 42, [[TRUE]] ], !dbg [[DBG17:![0-9]+]] |
| 25 | +; OPT-NEXT: call void @llvm.amdgcn.end.cf.i64(i64 [[TMP8]]) |
| 26 | +; OPT-NEXT: tail call void @llvm.dbg.value(metadata i32 [[RET]], metadata [[META11:![0-9]+]], metadata !DIExpression()), !dbg [[DBG17]] |
| 27 | +; OPT-NEXT: ret i32 [[RET]], !dbg [[DBG18:![0-9]+]] |
| 28 | +; |
| 29 | + %c = icmp eq i32 %0, 0, !dbg !13 |
| 30 | + tail call void @llvm.dbg.value(metadata i1 %c, metadata !9, metadata !DIExpression()), !dbg !13 |
| 31 | + br i1 %c, label %true, label %false, !dbg !14 |
| 32 | + |
| 33 | +true: ; preds = %1 |
| 34 | + br label %exit, !dbg !15 |
| 35 | + |
| 36 | +false: ; preds = %1 |
| 37 | + br label %exit, !dbg !16 |
| 38 | + |
| 39 | +exit: ; preds = %false, %true |
| 40 | + %ret = phi i32 [ 42, %true ], [ 33, %false ], !dbg !17 |
| 41 | + tail call void @llvm.dbg.value(metadata i32 %ret, metadata !11, metadata !DIExpression()), !dbg !17 |
| 42 | + ret i32 %ret, !dbg !18 |
| 43 | +} |
| 44 | + |
| 45 | +define amdgpu_ps void @loop_if_break(i32 %n) !dbg !19 { |
| 46 | +; OPT-LABEL: define amdgpu_ps void @loop_if_break( |
| 47 | +; OPT-SAME: i32 [[N:%.*]]) !dbg [[DBG19:![0-9]+]] { |
| 48 | +; OPT-NEXT: entry: |
| 49 | +; OPT-NEXT: br label [[LOOP:%.*]], !dbg [[DBG24:![0-9]+]] |
| 50 | +; OPT: loop: |
| 51 | +; OPT-NEXT: [[PHI_BROKEN:%.*]] = phi i64 [ [[TMP5:%.*]], [[FLOW:%.*]] ], [ 0, [[ENTRY:%.*]] ] |
| 52 | +; OPT-NEXT: [[I:%.*]] = phi i32 [ [[N]], [[ENTRY]] ], [ [[TMP3:%.*]], [[FLOW]] ], !dbg [[DBG25:![0-9]+]] |
| 53 | +; OPT-NEXT: tail call void @llvm.dbg.value(metadata i32 [[I]], metadata [[META21:![0-9]+]], metadata !DIExpression()), !dbg [[DBG25]] |
| 54 | +; OPT-NEXT: [[C:%.*]] = icmp ugt i32 [[I]], 0, !dbg [[DBG26:![0-9]+]] |
| 55 | +; OPT-NEXT: tail call void @llvm.dbg.value(metadata i1 [[C]], metadata [[META22:![0-9]+]], metadata !DIExpression()), !dbg [[DBG26]] |
| 56 | +; OPT-NEXT: [[TMP0:%.*]] = call { i1, i64 } @llvm.amdgcn.if.i64(i1 [[C]]) |
| 57 | +; OPT-NEXT: [[TMP1:%.*]] = extractvalue { i1, i64 } [[TMP0]], 0 |
| 58 | +; OPT-NEXT: [[TMP2:%.*]] = extractvalue { i1, i64 } [[TMP0]], 1 |
| 59 | +; OPT-NEXT: br i1 [[TMP1]], label [[LOOP_BODY:%.*]], label [[FLOW]], !dbg [[DBG27:![0-9]+]] |
| 60 | +; OPT: loop_body: |
| 61 | +; OPT-NEXT: [[I_NEXT:%.*]] = sub i32 [[I]], 1, !dbg [[DBG28:![0-9]+]] |
| 62 | +; OPT-NEXT: tail call void @llvm.dbg.value(metadata i32 [[I_NEXT]], metadata [[META23:![0-9]+]], metadata !DIExpression()), !dbg [[DBG28]] |
| 63 | +; OPT-NEXT: br label [[FLOW]], !dbg [[DBG29:![0-9]+]] |
| 64 | +; OPT: Flow: |
| 65 | +; OPT-NEXT: [[TMP3]] = phi i32 [ [[I_NEXT]], [[LOOP_BODY]] ], [ undef, [[LOOP]] ] |
| 66 | +; OPT-NEXT: [[TMP4:%.*]] = phi i1 [ false, [[LOOP_BODY]] ], [ true, [[LOOP]] ] |
| 67 | +; OPT-NEXT: call void @llvm.amdgcn.end.cf.i64(i64 [[TMP2]]) |
| 68 | +; OPT-NEXT: [[TMP5]] = call i64 @llvm.amdgcn.if.break.i64(i1 [[TMP4]], i64 [[PHI_BROKEN]]) |
| 69 | +; OPT-NEXT: [[TMP6:%.*]] = call i1 @llvm.amdgcn.loop.i64(i64 [[TMP5]]) |
| 70 | +; OPT-NEXT: br i1 [[TMP6]], label [[EXIT:%.*]], label [[LOOP]], !dbg [[DBG27]] |
| 71 | +; OPT: exit: |
| 72 | +; OPT-NEXT: call void @llvm.amdgcn.end.cf.i64(i64 [[TMP5]]) |
| 73 | +; OPT-NEXT: ret void, !dbg [[DBG30:![0-9]+]] |
| 74 | +; |
| 75 | +entry: |
| 76 | + br label %loop, !dbg !24 |
| 77 | + |
| 78 | +loop: ; preds = %loop_body, %entry |
| 79 | + %i = phi i32 [ %n, %entry ], [ %i.next, %loop_body ], !dbg !25 |
| 80 | + tail call void @llvm.dbg.value(metadata i32 %i, metadata !21, metadata !DIExpression()), !dbg !25 |
| 81 | + %c = icmp ugt i32 %i, 0, !dbg !26 |
| 82 | + tail call void @llvm.dbg.value(metadata i1 %c, metadata !22, metadata !DIExpression()), !dbg !26 |
| 83 | + br i1 %c, label %loop_body, label %exit, !dbg !27 |
| 84 | + |
| 85 | +loop_body: ; preds = %loop |
| 86 | + %i.next = sub i32 %i, 1, !dbg !28 |
| 87 | + tail call void @llvm.dbg.value(metadata i32 %i.next, metadata !23, metadata !DIExpression()), !dbg !28 |
| 88 | + br label %loop, !dbg !29 |
| 89 | + |
| 90 | +exit: ; preds = %loop |
| 91 | + ret void, !dbg !30 |
| 92 | +} |
| 93 | + |
| 94 | +; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none) |
| 95 | +declare void @llvm.dbg.value(metadata, metadata, metadata) #0 |
| 96 | + |
| 97 | +attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) } |
| 98 | + |
| 99 | +!llvm.dbg.cu = !{!0} |
| 100 | +!llvm.debugify = !{!2, !3} |
| 101 | +!llvm.module.flags = !{!4} |
| 102 | + |
| 103 | +!0 = distinct !DICompileUnit(language: DW_LANG_C, file: !1, producer: "debugify", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug) |
| 104 | +!1 = !DIFile(filename: "../../../test/CodeGen/AMDGPU/si-annotate-dbg-info.ll", directory: "/") |
| 105 | +!2 = !{i32 13} |
| 106 | +!3 = !{i32 5} |
| 107 | +!4 = !{i32 2, !"Debug Info Version", i32 3} |
| 108 | +!5 = distinct !DISubprogram(name: "if_else", linkageName: "if_else", scope: null, file: !1, line: 1, type: !6, scopeLine: 1, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !8) |
| 109 | +!6 = !DISubroutineType(types: !7) |
| 110 | +!7 = !{} |
| 111 | +!8 = !{!9, !11} |
| 112 | +!9 = !DILocalVariable(name: "1", scope: !5, file: !1, line: 1, type: !10) |
| 113 | +!10 = !DIBasicType(name: "ty8", size: 8, encoding: DW_ATE_unsigned) |
| 114 | +!11 = !DILocalVariable(name: "2", scope: !5, file: !1, line: 5, type: !12) |
| 115 | +!12 = !DIBasicType(name: "ty32", size: 32, encoding: DW_ATE_unsigned) |
| 116 | +!13 = !DILocation(line: 1, column: 1, scope: !5) |
| 117 | +!14 = !DILocation(line: 2, column: 1, scope: !5) |
| 118 | +!15 = !DILocation(line: 3, column: 1, scope: !5) |
| 119 | +!16 = !DILocation(line: 4, column: 1, scope: !5) |
| 120 | +!17 = !DILocation(line: 5, column: 1, scope: !5) |
| 121 | +!18 = !DILocation(line: 6, column: 1, scope: !5) |
| 122 | +!19 = distinct !DISubprogram(name: "loop_if_break", linkageName: "loop_if_break", scope: null, file: !1, line: 7, type: !6, scopeLine: 7, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !20) |
| 123 | +!20 = !{!21, !22, !23} |
| 124 | +!21 = !DILocalVariable(name: "3", scope: !19, file: !1, line: 8, type: !12) |
| 125 | +!22 = !DILocalVariable(name: "4", scope: !19, file: !1, line: 9, type: !10) |
| 126 | +!23 = !DILocalVariable(name: "5", scope: !19, file: !1, line: 11, type: !12) |
| 127 | +!24 = !DILocation(line: 7, column: 1, scope: !19) |
| 128 | +!25 = !DILocation(line: 8, column: 1, scope: !19) |
| 129 | +!26 = !DILocation(line: 9, column: 1, scope: !19) |
| 130 | +!27 = !DILocation(line: 10, column: 1, scope: !19) |
| 131 | +!28 = !DILocation(line: 11, column: 1, scope: !19) |
| 132 | +!29 = !DILocation(line: 12, column: 1, scope: !19) |
| 133 | +!30 = !DILocation(line: 13, column: 1, scope: !19) |
| 134 | +;. |
| 135 | +; OPT: [[META0:![0-9]+]] = distinct !DICompileUnit(language: DW_LANG_C, file: [[META1:![0-9]+]], producer: "debugify", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug) |
| 136 | +; OPT: [[META1]] = !DIFile(filename: "../../../test/CodeGen/AMDGPU/si-annotate-dbg-info.ll", directory: {{.*}}) |
| 137 | +; OPT: [[DBG5]] = distinct !DISubprogram(name: "if_else", linkageName: "if_else", scope: null, file: [[META1]], line: 1, type: [[META6:![0-9]+]], scopeLine: 1, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: [[META0]], retainedNodes: [[META8:![0-9]+]]) |
| 138 | +; OPT: [[META6]] = !DISubroutineType(types: [[META7:![0-9]+]]) |
| 139 | +; OPT: [[META7]] = !{} |
| 140 | +; OPT: [[META8]] = !{[[META9]], [[META11]]} |
| 141 | +; OPT: [[META9]] = !DILocalVariable(name: "1", scope: [[DBG5]], file: [[META1]], line: 1, type: [[META10:![0-9]+]]) |
| 142 | +; OPT: [[META10]] = !DIBasicType(name: "ty8", size: 8, encoding: DW_ATE_unsigned) |
| 143 | +; OPT: [[META11]] = !DILocalVariable(name: "2", scope: [[DBG5]], file: [[META1]], line: 5, type: [[META12:![0-9]+]]) |
| 144 | +; OPT: [[META12]] = !DIBasicType(name: "ty32", size: 32, encoding: DW_ATE_unsigned) |
| 145 | +; OPT: [[DBG13]] = !DILocation(line: 1, column: 1, scope: [[DBG5]]) |
| 146 | +; OPT: [[DBG14]] = !DILocation(line: 2, column: 1, scope: [[DBG5]]) |
| 147 | +; OPT: [[DBG15]] = !DILocation(line: 3, column: 1, scope: [[DBG5]]) |
| 148 | +; OPT: [[DBG16]] = !DILocation(line: 4, column: 1, scope: [[DBG5]]) |
| 149 | +; OPT: [[DBG17]] = !DILocation(line: 5, column: 1, scope: [[DBG5]]) |
| 150 | +; OPT: [[DBG18]] = !DILocation(line: 6, column: 1, scope: [[DBG5]]) |
| 151 | +; OPT: [[DBG19]] = distinct !DISubprogram(name: "loop_if_break", linkageName: "loop_if_break", scope: null, file: [[META1]], line: 7, type: [[META6]], scopeLine: 7, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: [[META0]], retainedNodes: [[META20:![0-9]+]]) |
| 152 | +; OPT: [[META20]] = !{[[META21]], [[META22]], [[META23]]} |
| 153 | +; OPT: [[META21]] = !DILocalVariable(name: "3", scope: [[DBG19]], file: [[META1]], line: 8, type: [[META12]]) |
| 154 | +; OPT: [[META22]] = !DILocalVariable(name: "4", scope: [[DBG19]], file: [[META1]], line: 9, type: [[META10]]) |
| 155 | +; OPT: [[META23]] = !DILocalVariable(name: "5", scope: [[DBG19]], file: [[META1]], line: 11, type: [[META12]]) |
| 156 | +; OPT: [[DBG24]] = !DILocation(line: 7, column: 1, scope: [[DBG19]]) |
| 157 | +; OPT: [[DBG25]] = !DILocation(line: 8, column: 1, scope: [[DBG19]]) |
| 158 | +; OPT: [[DBG26]] = !DILocation(line: 9, column: 1, scope: [[DBG19]]) |
| 159 | +; OPT: [[DBG27]] = !DILocation(line: 10, column: 1, scope: [[DBG19]]) |
| 160 | +; OPT: [[DBG28]] = !DILocation(line: 11, column: 1, scope: [[DBG19]]) |
| 161 | +; OPT: [[DBG29]] = !DILocation(line: 12, column: 1, scope: [[DBG19]]) |
| 162 | +; OPT: [[DBG30]] = !DILocation(line: 13, column: 1, scope: [[DBG19]]) |
| 163 | +;. |
0 commit comments