xref: /llvm-project/llvm/test/Transforms/DivRemPairs/X86/preserving-debugloc-frx-fry-mul-sub.ll (revision 3ae6755719c6dfc07761b4e9bdac8c86bcb41734)
1; RUN: opt -S -passes=div-rem-pairs -mtriple=x86_64-unknown-unknown < %s | FileCheck %s
2
3; Check that DivRemPairs's optimizeDivRem() correctly propagates debug locations
4; of `%div` and `%rem` to new freeze, mul and sub instructions.
5
6define i128 @dont_hoist_urem(i128 %a, i128 %b) !dbg !5 {
7; CHECK-LABEL: define i128 @dont_hoist_urem(
8; CHECK-SAME: i128 [[A:%.*]], i128 [[B:%.*]])
9; CHECK:       entry:
10; CHECK-NEXT:    [[A_FROZEN:%.*]] = freeze i128 [[A]], !dbg [[DBG8:![0-9]+]]
11; CHECK-NEXT:    [[B_FROZEN:%.*]] = freeze i128 [[B]], !dbg [[DBG8]]
12; CHECK:       if:
13; CHECK-NEXT:    [[TMP0:%.*]] = mul i128 [[DIV:%.*]], [[B_FROZEN]], !dbg [[DBG11:![0-9]+]]
14; CHECK-NEXT:    [[REM_DECOMPOSED:%.*]] = sub i128 [[A_FROZEN]], [[TMP0:%.*]], !dbg [[DBG11]]
15; CHECK:       end:
16entry:
17  %div = udiv i128 %a, %b, !dbg !8
18  %cmp = icmp eq i128 %div, 42, !dbg !9
19  br i1 %cmp, label %if, label %end, !dbg !10
20
21if:                                               ; preds = %entry
22  %rem = urem i128 %a, %b, !dbg !11
23  br label %end, !dbg !12
24
25end:                                              ; preds = %if, %entry
26  %ret = phi i128 [ %rem, %if ], [ 3, %entry ], !dbg !13
27  ret i128 %ret, !dbg !14
28}
29
30!llvm.dbg.cu = !{!0}
31!llvm.debugify = !{!2, !3}
32!llvm.module.flags = !{!4}
33
34!0 = distinct !DICompileUnit(language: DW_LANG_C, file: !1, producer: "debugify", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug)
35!1 = !DIFile(filename: "frx_fry_.preserve.ll", directory: "/")
36!2 = !{i32 7}
37!3 = !{i32 0}
38!4 = !{i32 2, !"Debug Info Version", i32 3}
39!5 = distinct !DISubprogram(name: "dont_hoist_urem", linkageName: "dont_hoist_urem", scope: null, file: !1, line: 1, type: !6, scopeLine: 1, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0)
40!6 = !DISubroutineType(types: !7)
41!7 = !{}
42!8 = !DILocation(line: 1, column: 1, scope: !5)
43!9 = !DILocation(line: 2, column: 1, scope: !5)
44!10 = !DILocation(line: 3, column: 1, scope: !5)
45!11 = !DILocation(line: 4, column: 1, scope: !5)
46!12 = !DILocation(line: 5, column: 1, scope: !5)
47!13 = !DILocation(line: 6, column: 1, scope: !5)
48!14 = !DILocation(line: 7, column: 1, scope: !5)
49; CHECK: [[DBG8]] = !DILocation(line: 1,
50; CHECK: [[DBG11]] = !DILocation(line: 4,
51