1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown | FileCheck %s
4 ; Checks if "%7 = add nuw nsw i64 %4, %2" is moved before the last call
5 ; to minimize live-range.
7 define i64 @test(i1 %a, i64 %r1, i64 %r2, i64 %s1, i64 %s2, i64 %t1, i64 %t2) {
9 ; CHECK: # %bb.0: # %entry
10 ; CHECK-NEXT: pushq %r15
11 ; CHECK-NEXT: .cfi_def_cfa_offset 16
12 ; CHECK-NEXT: pushq %r14
13 ; CHECK-NEXT: .cfi_def_cfa_offset 24
14 ; CHECK-NEXT: pushq %rbx
15 ; CHECK-NEXT: .cfi_def_cfa_offset 32
16 ; CHECK-NEXT: .cfi_offset %rbx, -32
17 ; CHECK-NEXT: .cfi_offset %r14, -24
18 ; CHECK-NEXT: .cfi_offset %r15, -16
19 ; CHECK-NEXT: movq %rcx, %r14
20 ; CHECK-NEXT: movl $4, %r15d
21 ; CHECK-NEXT: testb $1, %dil
22 ; CHECK-NEXT: je .LBB0_2
23 ; CHECK-NEXT: # %bb.1: # %then
24 ; CHECK-NEXT: movq {{[0-9]+}}(%rsp), %r9
25 ; CHECK-NEXT: movl $10, %r15d
26 ; CHECK-NEXT: movq %rdx, %rsi
27 ; CHECK-NEXT: movq %r8, %r14
28 ; CHECK-NEXT: .LBB0_2: # %else
29 ; CHECK-NEXT: addq %r9, %r14
30 ; CHECK-NEXT: addq %rsi, %r15
31 ; CHECK-NEXT: callq _Z3foov@PLT
32 ; CHECK-NEXT: movl %eax, %ebx
33 ; CHECK-NEXT: addq %r15, %rbx
34 ; CHECK-NEXT: callq _Z3foov@PLT
35 ; CHECK-NEXT: movl %eax, %r15d
36 ; CHECK-NEXT: addq %rbx, %r15
37 ; CHECK-NEXT: callq _Z3foov@PLT
38 ; CHECK-NEXT: movl %eax, %eax
39 ; CHECK-NEXT: addq %r15, %rax
40 ; CHECK-NEXT: addq %r14, %rax
41 ; CHECK-NEXT: popq %rbx
42 ; CHECK-NEXT: .cfi_def_cfa_offset 24
43 ; CHECK-NEXT: popq %r14
44 ; CHECK-NEXT: .cfi_def_cfa_offset 16
45 ; CHECK-NEXT: popq %r15
46 ; CHECK-NEXT: .cfi_def_cfa_offset 8
49 br i1 %a, label %then, label %else
55 %0 = phi i64 [ 4, %entry ], [ 10, %then ]
56 %r = phi i64 [ %r1, %entry ], [ %r2, %then ]
57 %s = phi i64 [ %s1, %entry ], [ %s2, %then ]
58 %t = phi i64 [ %t1, %entry ], [ %t2, %then ]
59 %1 = tail call i32 @_Z3foov()
60 %2 = zext i32 %1 to i64
61 %3 = tail call i32 @_Z3foov()
62 %4 = zext i32 %3 to i64
63 %5 = tail call i32 @_Z3foov()
64 %6 = zext i32 %5 to i64
65 %7 = add nuw nsw i64 %0, %r
66 tail call void @llvm.dbg.value(metadata i64 %7, i64 0, metadata !5, metadata !DIExpression()), !dbg !6
67 %8 = add nuw nsw i64 %2, %7
68 %9 = add nuw nsw i64 %4, %8
69 %10 = add nuw nsw i64 %6, %9
70 %11 = add nuw nsw i64 %s, %t
71 tail call void @llvm.dbg.value(metadata i64 %11, i64 0, metadata !5, metadata !DIExpression()), !dbg !6
72 %12 = add nuw nsw i64 %10, %11
76 declare i32 @_Z3foov()
77 declare void @llvm.dbg.value(metadata, i64, metadata, metadata)
80 !llvm.module.flags = !{!1, !2}
82 !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !3, emissionKind: FullDebug)
83 !1 = !{i32 2, !"Dwarf Version", i32 4}
84 !2 = !{i32 2, !"Debug Info Version", i32 3}
85 !3 = !DIFile(filename: "a.c", directory: "./")
86 !4 = distinct !DISubprogram(name: "test", scope: !3, unit: !0)
87 !5 = !DILocalVariable(name: "x", scope: !4)
88 !6 = !DILocation(line: 4, scope: !4)