Dehao Chen | 6b737dd | 2017-05-31 23:25:25 +0000 | [diff] [blame^] | 1 | ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py |
| 2 | ; RUN: llc < %s -mtriple=x86_64-unknown-unknown | FileCheck %s |
| 3 | |
| 4 | ; Checks if "%7 = add nuw nsw i64 %4, %2" is moved before the last call |
| 5 | ; to minimize live-range. |
| 6 | |
| 7 | define i64 @test(i1 %a, i64 %r1, i64 %r2, i64 %s1, i64 %s2, i64 %t1, i64 %t2) { |
| 8 | entry: |
| 9 | br i1 %a, label %then, label %else |
| 10 | |
| 11 | then: |
| 12 | br label %else |
| 13 | |
| 14 | else: |
| 15 | %0 = phi i64 [ 4, %entry ], [ 10, %then ] |
| 16 | %r = phi i64 [ %r1, %entry ], [ %r2, %then ] |
| 17 | %s = phi i64 [ %s1, %entry ], [ %s2, %then ] |
| 18 | %t = phi i64 [ %t1, %entry ], [ %t2, %then ] |
| 19 | ; CHECK-LABEL: test: |
| 20 | ; CHECK: add |
| 21 | ; CHECK: add |
| 22 | ; CHECK: call |
| 23 | ; CHECK: add |
| 24 | ; CHECK: call |
| 25 | ; CHECK: add |
| 26 | ; CHECK: call |
| 27 | ; CHECK: add |
| 28 | %1 = tail call i32 @_Z3foov() |
| 29 | %2 = zext i32 %1 to i64 |
| 30 | %3 = tail call i32 @_Z3foov() |
| 31 | %4 = zext i32 %3 to i64 |
| 32 | %5 = tail call i32 @_Z3foov() |
| 33 | %6 = zext i32 %5 to i64 |
| 34 | %7 = add nuw nsw i64 %0, %r |
| 35 | tail call void @llvm.dbg.value(metadata i64 %7, i64 0, metadata !5, metadata !DIExpression()), !dbg !6 |
| 36 | %8 = add nuw nsw i64 %2, %7 |
| 37 | %9 = add nuw nsw i64 %4, %8 |
| 38 | %10 = add nuw nsw i64 %6, %9 |
| 39 | %11 = add nuw nsw i64 %s, %t |
| 40 | tail call void @llvm.dbg.value(metadata i64 %11, i64 0, metadata !5, metadata !DIExpression()), !dbg !6 |
| 41 | %12 = add nuw nsw i64 %10, %11 |
| 42 | ret i64 %12 |
| 43 | } |
| 44 | |
| 45 | declare i32 @_Z3foov() |
| 46 | declare void @llvm.dbg.value(metadata, i64, metadata, metadata) |
| 47 | |
| 48 | !llvm.dbg.cu = !{!0} |
| 49 | !llvm.module.flags = !{!1, !2} |
| 50 | |
| 51 | !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !3, emissionKind: FullDebug) |
| 52 | !1 = !{i32 2, !"Dwarf Version", i32 4} |
| 53 | !2 = !{i32 2, !"Debug Info Version", i32 3} |
| 54 | !3 = !DIFile(filename: "a.c", directory: "./") |
| 55 | !4 = distinct !DISubprogram(name: "test", scope: !3, unit: !0) |
| 56 | !5 = !DILocalVariable(name: "x", scope: !4) |
| 57 | !6 = !DILocation(line: 4, scope: !4) |