1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -S -mtriple=amdgcn-amd-amdhsa -codegenprepare %s | FileCheck %s
3 ; Make sure BypassSlowDivision doesn't drop debug info
5 define i64 @sdiv64(i64 %a, i64 %b) {
6 ; CHECK-LABEL: @sdiv64(
7 ; CHECK-NEXT: [[TMP1:%.*]] = or i64 [[A:%.*]], [[B:%.*]], !dbg !6
8 ; CHECK-NEXT: [[TMP2:%.*]] = and i64 [[TMP1]], -4294967296, !dbg !6
9 ; CHECK-NEXT: [[TMP3:%.*]] = icmp eq i64 [[TMP2]], 0, !dbg !6
10 ; CHECK-NEXT: br i1 [[TMP3]], label [[TMP4:%.*]], label [[TMP9:%.*]], !dbg !6
12 ; CHECK-NEXT: [[TMP5:%.*]] = trunc i64 [[B]] to i32, !dbg !6
13 ; CHECK-NEXT: [[TMP6:%.*]] = trunc i64 [[A]] to i32, !dbg !6
14 ; CHECK-NEXT: [[TMP7:%.*]] = udiv i32 [[TMP6]], [[TMP5]], !dbg !6
15 ; CHECK-NEXT: [[TMP8:%.*]] = zext i32 [[TMP7]] to i64, !dbg !6
16 ; CHECK-NEXT: br label [[TMP11:%.*]], !dbg !6
18 ; CHECK-NEXT: [[TMP10:%.*]] = sdiv i64 [[A]], [[B]], !dbg !6
19 ; CHECK-NEXT: br label [[TMP11]], !dbg !6
21 ; CHECK-NEXT: [[TMP12:%.*]] = phi i64 [ [[TMP8]], [[TMP4]] ], [ [[TMP10]], [[TMP9]] ], !dbg !6
22 ; CHECK-NEXT: ret i64 [[TMP12]]
24 %d = sdiv i64 %a, %b, !dbg !6
28 ; FIXME: The debugloc for the rem parts end up with the dbg of the
30 define <2 x i64> @sdivrem64(i64 %a, i64 %b) {
31 ; CHECK-LABEL: @sdivrem64(
32 ; CHECK-NEXT: [[TMP1:%.*]] = or i64 [[A:%.*]], [[B:%.*]], !dbg !6
33 ; CHECK-NEXT: [[TMP2:%.*]] = and i64 [[TMP1]], -4294967296, !dbg !6
34 ; CHECK-NEXT: [[TMP3:%.*]] = icmp eq i64 [[TMP2]], 0, !dbg !6
35 ; CHECK-NEXT: br i1 [[TMP3]], label [[TMP4:%.*]], label [[TMP11:%.*]], !dbg !6
37 ; CHECK-NEXT: [[TMP5:%.*]] = trunc i64 [[B]] to i32, !dbg !6
38 ; CHECK-NEXT: [[TMP6:%.*]] = trunc i64 [[A]] to i32, !dbg !6
39 ; CHECK-NEXT: [[TMP7:%.*]] = udiv i32 [[TMP6]], [[TMP5]], !dbg !6
40 ; CHECK-NEXT: [[TMP8:%.*]] = urem i32 [[TMP6]], [[TMP5]], !dbg !6
41 ; CHECK-NEXT: [[TMP9:%.*]] = zext i32 [[TMP7]] to i64, !dbg !6
42 ; CHECK-NEXT: [[TMP10:%.*]] = zext i32 [[TMP8]] to i64, !dbg !6
43 ; CHECK-NEXT: br label [[TMP14:%.*]], !dbg !6
45 ; CHECK-NEXT: [[TMP12:%.*]] = sdiv i64 [[A]], [[B]], !dbg !6
46 ; CHECK-NEXT: [[TMP13:%.*]] = srem i64 [[A]], [[B]], !dbg !6
47 ; CHECK-NEXT: br label [[TMP14]], !dbg !6
49 ; CHECK-NEXT: [[TMP15:%.*]] = phi i64 [ [[TMP9]], [[TMP4]] ], [ [[TMP12]], [[TMP11]] ], !dbg !6
50 ; CHECK-NEXT: [[TMP16:%.*]] = phi i64 [ [[TMP10]], [[TMP4]] ], [ [[TMP13]], [[TMP11]] ], !dbg !6
51 ; CHECK-NEXT: [[INS0:%.*]] = insertelement <2 x i64> undef, i64 [[TMP15]], i32 0
52 ; CHECK-NEXT: [[INS1:%.*]] = insertelement <2 x i64> [[INS0]], i64 [[TMP16]], i32 1
53 ; CHECK-NEXT: ret <2 x i64> [[INS1]]
55 %d = sdiv i64 %a, %b, !dbg !6
56 %r = srem i64 %a, %b, !dbg !10
57 %ins0 = insertelement <2 x i64> undef, i64 %d, i32 0
58 %ins1 = insertelement <2 x i64> %ins0, i64 %r, i32 1
63 !llvm.module.flags = !{!3, !4}
66 !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 3.5 ", isOptimized: false, runtimeVersion: 0, emissionKind: NoDebug, enums: !2, retainedTypes: !2, globals: !2, imports: !2)
67 !1 = !DIFile(filename: "basic.c", directory: ".")
69 !3 = !{i32 2, !"Dwarf Version", i32 4}
70 !4 = !{i32 1, !"Debug Info Version", i32 3}
71 !5 = !{!"clang version 3.5 "}
72 !6 = !DILocation(line: 3, scope: !7)
73 !7 = distinct !DILexicalBlock(scope: !8, file: !1, line: 3)
74 !8 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 1, type: !9, scopeLine: 1, virtualIndex: 6, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2)
75 !9 = !DISubroutineType(types: !2)
76 !10 = !DILocation(line: 4, scope: !7)