Jun Bum Lim | b389d9b | 2016-02-16 20:02:39 +0000 | [diff] [blame] | 1 | ; RUN: llc -mtriple=aarch64-linux-gnu -mcpu=cortex-a57 -verify-machineinstrs < %s | FileCheck %s |
| 2 | |
Tim Northover | 3f22856 | 2016-02-17 21:16:53 +0000 | [diff] [blame] | 3 | ; CHECK-LABEL: f_XX: |
Jun Bum Lim | b389d9b | 2016-02-16 20:02:39 +0000 | [diff] [blame] | 4 | ; CHECK: cbz x[[REG:[0-9]+]], [[BB:.LBB.*]] |
| 5 | ; CHECK: [[BB]]: |
| 6 | ; CHECK-NOT: mov x[[REG]], xzr |
| 7 | define i64 @f_XX(i64 %n, i64* nocapture readonly %P) { |
| 8 | entry: |
| 9 | %tobool = icmp eq i64 %n, 0 |
| 10 | br i1 %tobool, label %if.end, label %if.then |
| 11 | |
| 12 | if.then: ; preds = %entry |
| 13 | %0 = load i64, i64* %P |
| 14 | br label %if.end |
| 15 | |
| 16 | if.end: ; preds = %entry, %if.then |
| 17 | %a.0 = phi i64 [ %0, %if.then ], [ 0, %entry ] |
| 18 | ret i64 %a.0 |
| 19 | } |
| 20 | |
Tim Northover | 3f22856 | 2016-02-17 21:16:53 +0000 | [diff] [blame] | 21 | ; CHECK-LABEL: f_WW: |
Jun Bum Lim | b389d9b | 2016-02-16 20:02:39 +0000 | [diff] [blame] | 22 | ; CHECK: cbz w[[REG:[0-9]+]], [[BB:.LBB.*]] |
| 23 | ; CHECK: [[BB]]: |
| 24 | ; CHECK-NOT: mov w[[REG]], wzr |
| 25 | define i32 @f_WW(i32 %n, i32* nocapture readonly %P) { |
| 26 | entry: |
| 27 | %tobool = icmp eq i32 %n, 0 |
| 28 | br i1 %tobool, label %if.end, label %if.then |
| 29 | |
| 30 | if.then: ; preds = %entry |
| 31 | %0 = load i32, i32* %P |
| 32 | br label %if.end |
| 33 | |
| 34 | if.end: ; preds = %entry, %if.then |
| 35 | %a.0 = phi i32 [ %0, %if.then ], [ 0, %entry ] |
| 36 | ret i32 %a.0 |
| 37 | } |
| 38 | |
Tim Northover | 3f22856 | 2016-02-17 21:16:53 +0000 | [diff] [blame] | 39 | ; CHECK-LABEL: f_XW: |
Jun Bum Lim | b389d9b | 2016-02-16 20:02:39 +0000 | [diff] [blame] | 40 | ; CHECK: cbz x[[REG:[0-9]+]], [[BB:.LBB.*]] |
| 41 | ; CHECK: [[BB]]: |
| 42 | ; CHECK-NOT: mov w[[REG]], wzr |
| 43 | define i32 @f_XW(i64 %n, i32* nocapture readonly %P) { |
| 44 | entry: |
| 45 | %tobool = icmp eq i64 %n, 0 |
| 46 | br i1 %tobool, label %if.end, label %if.then |
| 47 | |
| 48 | if.then: ; preds = %entry |
| 49 | %0 = load i32, i32* %P |
| 50 | br label %if.end |
| 51 | |
| 52 | if.end: ; preds = %entry, %if.then |
| 53 | %a.0 = phi i32 [ %0, %if.then ], [ 0, %entry ] |
| 54 | ret i32 %a.0 |
| 55 | } |
| 56 | |
Tim Northover | 3f22856 | 2016-02-17 21:16:53 +0000 | [diff] [blame] | 57 | ; CHECK-LABEL: f_WX: |
Jun Bum Lim | b389d9b | 2016-02-16 20:02:39 +0000 | [diff] [blame] | 58 | ; CHECK: cbz w[[REG:[0-9]+]], [[BB:.LBB.*]] |
| 59 | ; CHECK: [[BB]]: |
| 60 | ; CHECK: mov x[[REG]], xzr |
| 61 | ; Do not remove the mov in this case because we do not know if the upper bits |
| 62 | ; of the X register are zero. |
| 63 | define i64 @f_WX(i32 %n, i64* nocapture readonly %P) { |
| 64 | entry: |
| 65 | %tobool = icmp eq i32 %n, 0 |
| 66 | br i1 %tobool, label %if.end, label %if.then |
| 67 | |
| 68 | if.then: ; preds = %entry |
| 69 | %0 = load i64, i64* %P |
| 70 | br label %if.end |
| 71 | |
| 72 | if.end: ; preds = %entry, %if.then |
| 73 | %a.0 = phi i64 [ %0, %if.then ], [ 0, %entry ] |
| 74 | ret i64 %a.0 |
| 75 | } |
Tim Northover | 3f22856 | 2016-02-17 21:16:53 +0000 | [diff] [blame] | 76 | |
| 77 | ; CHECK-LABEL: test_superreg: |
| 78 | ; CHECK: cbz x[[REG:[0-9]+]], [[BB:.LBB.*]] |
| 79 | ; CHECK: [[BB]]: |
| 80 | ; CHECK: str x[[REG]], [x1] |
| 81 | ; CHECK-NOT: mov w[[REG]], wzr |
| 82 | ; Because we returned w0 but x0 was marked live-in to the block, we didn't |
| 83 | ; remove the <kill> on the str leading to a verification failure. |
| 84 | define i32 @test_superreg(i64 %in, i64* %dest) { |
| 85 | %tst = icmp eq i64 %in, 0 |
| 86 | br i1 %tst, label %true, label %false |
| 87 | |
| 88 | false: |
| 89 | ret i32 42 |
| 90 | |
| 91 | true: |
| 92 | store volatile i64 %in, i64* %dest |
| 93 | ret i32 0 |
Tim Northover | 7687bce | 2016-02-17 23:07:04 +0000 | [diff] [blame^] | 94 | } |