1 # RUN: llc -march=hexagon -run-pass hwloops -o - %s | FileCheck %s
3 # This used to crash with `Assertion `isReg() && "This is not a register operand!"`
7 target datalayout = "e-m:e-p:32:32:32-a:0-n16:32-i64:64:64-i32:32:32-i16:16:16-i1:8:8-f32:32:32-f64:64:64-v32:32:32-v64:64:64-v512:512:512-v1024:1024:1024-v2048:2048:2048"
8 target triple = "hexagon"
12 @g0 = external dso_local local_unnamed_addr global ptr, align 4, !dbg !0
14 define dso_local void @f0() local_unnamed_addr #0 !dbg !13 {
16 %v0 = sext i16 undef to i32
17 br i1 undef, label %b2, label %b1
19 b1: ; preds = %b1, %b0
20 %v1 = phi i32 [ %v2, %b1 ], [ undef, %b0 ]
21 %v2 = add nsw i32 %v1, -8
22 %v3 = add nsw i32 %v2, %v0
23 call void @llvm.dbg.value(metadata i32 %v3, metadata !19, metadata !DIExpression()), !dbg !24
24 %v4 = load ptr, ptr @g0, align 4
25 %v5 = getelementptr inbounds %s.0, ptr %v4, i32 %v3, i32 0
26 store i32 undef, ptr %v5, align 4
27 %v6 = icmp eq i32 %v2, 0
28 br i1 %v6, label %b2, label %b1
30 b2: ; preds = %b1, %b0
34 declare void @llvm.dbg.value(metadata, metadata, metadata) #1
36 attributes #0 = { "target-features"="+v66,-long-calls" }
37 attributes #1 = { nofree nosync nounwind readnone speculatable willreturn }
40 !llvm.module.flags = !{!11, !12}
42 !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
43 !1 = distinct !DIGlobalVariable(name: "g0", scope: !2, file: !3, line: 3, type: !6, isLocal: false, isDefinition: true)
44 !2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang version 13.0.0 (https://github.com/llvm/llvm-project 93664503be6b3f47269cf617f8c46b6ce95f8076)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5, splitDebugInlining: false, nameTableKind: None)
45 !3 = !DIFile(filename: "dev.i", directory: "/test")
48 !6 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !7, size: 32)
49 !7 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "s.0", file: !3, line: 1, size: 32, elements: !8)
51 !9 = !DIDerivedType(tag: DW_TAG_member, name: "m", scope: !7, file: !3, line: 2, baseType: !10, size: 32)
52 !10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
53 !11 = !{i32 2, !"Debug Info Version", i32 3}
54 !12 = !{i32 7, !"frame-pointer", i32 2}
55 !13 = distinct !DISubprogram(name: "f0", scope: !3, file: !3, line: 9, type: !14, scopeLine: 9, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !17)
56 !14 = !DISubroutineType(types: !15)
58 !16 = !DIBasicType(name: "unsigned short", size: 16, encoding: DW_ATE_unsigned)
60 !18 = !DILocalVariable(name: "x", arg: 1, scope: !13, file: !3, line: 9, type: !16)
61 !19 = !DILocalVariable(name: "y", arg: 1, scope: !20, file: !3, line: 6, type: !10)
62 !20 = distinct !DISubprogram(name: "f1", scope: !3, file: !3, line: 6, type: !21, scopeLine: 6, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !23)
63 !21 = !DISubroutineType(types: !22)
66 !24 = !DILocation(line: 0, scope: !20, inlinedAt: !25)
67 !25 = distinct !DILocation(line: 11, column: 5, scope: !13)
73 tracksRegLiveness: true
76 successors: %bb.2(0x40000000), %bb.3(0x40000000); %bb.2(50.00%), %bb.3(50.00%)
78 %6:predregs = IMPLICIT_DEF
79 J2_jumpt %6:predregs, %bb.2, implicit-def $pc
82 successors: %bb.1(0x80000000); %bb.1(100.00%)
84 %5:intregs = IMPLICIT_DEF
85 %4:intregs = A2_tfrsi 0
88 successors: %bb.2(0x04000000), %bb.1(0x7c000000); %bb.2(3.12%), %bb.1(96.88%)
90 %0:intregs = PHI %4:intregs, %bb.3, %3:intregs, %bb.1
91 %1:intregs = PHI %5:intregs, %bb.3, %2:intregs, %bb.1
92 %2:intregs = nsw A2_addi %1:intregs, -8
93 DBG_VALUE_LIST !19, !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_LLVM_arg, 1, DW_OP_plus, DW_OP_stack_value), %2:intregs, 0, debug-location !24
94 %3:intregs = A2_addi %0:intregs, -32
95 %7:predregs = C2_cmpeqi %2:intregs, 0
96 J2_jumpf %7:predregs, %bb.1, implicit-def dead $pc
97 J2_jump %bb.2, implicit-def dead $pc
100 PS_jmpret $r31, implicit-def dead $pc