[AArch64] Add pass to remove redundant copy after RA
Summary:
This change will add a pass to remove unnecessary zero copies in target blocks
of cbz/cbnz instructions. E.g., the copy instruction in the code below can be
removed because the cbz jumps to BB1 when x0 is zero :
BB0:
cbz x0, .BB1
BB1:
mov x0, xzr
Jun
Reviewers: gberry, jmolloy, HaoLiu, MatzeB, mcrosier
Subscribers: mcrosier, mssimpso, haicheng, bmakam, llvm-commits, aemerson, rengolin
Differential Revision: http://reviews.llvm.org/D16203
llvm-svn: 261004
2016-02-17 04:02:39 +08:00
|
|
|
; RUN: llc -mtriple=aarch64-linux-gnu -mcpu=cortex-a57 -verify-machineinstrs < %s | FileCheck %s
|
|
|
|
|
2016-02-18 05:16:53 +08:00
|
|
|
; CHECK-LABEL: f_XX:
|
[AArch64] Add pass to remove redundant copy after RA
Summary:
This change will add a pass to remove unnecessary zero copies in target blocks
of cbz/cbnz instructions. E.g., the copy instruction in the code below can be
removed because the cbz jumps to BB1 when x0 is zero :
BB0:
cbz x0, .BB1
BB1:
mov x0, xzr
Jun
Reviewers: gberry, jmolloy, HaoLiu, MatzeB, mcrosier
Subscribers: mcrosier, mssimpso, haicheng, bmakam, llvm-commits, aemerson, rengolin
Differential Revision: http://reviews.llvm.org/D16203
llvm-svn: 261004
2016-02-17 04:02:39 +08:00
|
|
|
; CHECK: cbz x[[REG:[0-9]+]], [[BB:.LBB.*]]
|
|
|
|
; CHECK: [[BB]]:
|
|
|
|
; CHECK-NOT: mov x[[REG]], xzr
|
|
|
|
define i64 @f_XX(i64 %n, i64* nocapture readonly %P) {
|
|
|
|
entry:
|
|
|
|
%tobool = icmp eq i64 %n, 0
|
|
|
|
br i1 %tobool, label %if.end, label %if.then
|
|
|
|
|
|
|
|
if.then: ; preds = %entry
|
|
|
|
%0 = load i64, i64* %P
|
|
|
|
br label %if.end
|
|
|
|
|
|
|
|
if.end: ; preds = %entry, %if.then
|
|
|
|
%a.0 = phi i64 [ %0, %if.then ], [ 0, %entry ]
|
|
|
|
ret i64 %a.0
|
|
|
|
}
|
|
|
|
|
2016-02-18 05:16:53 +08:00
|
|
|
; CHECK-LABEL: f_WW:
|
[AArch64] Add pass to remove redundant copy after RA
Summary:
This change will add a pass to remove unnecessary zero copies in target blocks
of cbz/cbnz instructions. E.g., the copy instruction in the code below can be
removed because the cbz jumps to BB1 when x0 is zero :
BB0:
cbz x0, .BB1
BB1:
mov x0, xzr
Jun
Reviewers: gberry, jmolloy, HaoLiu, MatzeB, mcrosier
Subscribers: mcrosier, mssimpso, haicheng, bmakam, llvm-commits, aemerson, rengolin
Differential Revision: http://reviews.llvm.org/D16203
llvm-svn: 261004
2016-02-17 04:02:39 +08:00
|
|
|
; CHECK: cbz w[[REG:[0-9]+]], [[BB:.LBB.*]]
|
|
|
|
; CHECK: [[BB]]:
|
|
|
|
; CHECK-NOT: mov w[[REG]], wzr
|
|
|
|
define i32 @f_WW(i32 %n, i32* nocapture readonly %P) {
|
|
|
|
entry:
|
|
|
|
%tobool = icmp eq i32 %n, 0
|
|
|
|
br i1 %tobool, label %if.end, label %if.then
|
|
|
|
|
|
|
|
if.then: ; preds = %entry
|
|
|
|
%0 = load i32, i32* %P
|
|
|
|
br label %if.end
|
|
|
|
|
|
|
|
if.end: ; preds = %entry, %if.then
|
|
|
|
%a.0 = phi i32 [ %0, %if.then ], [ 0, %entry ]
|
|
|
|
ret i32 %a.0
|
|
|
|
}
|
|
|
|
|
2016-02-18 05:16:53 +08:00
|
|
|
; CHECK-LABEL: f_XW:
|
[AArch64] Add pass to remove redundant copy after RA
Summary:
This change will add a pass to remove unnecessary zero copies in target blocks
of cbz/cbnz instructions. E.g., the copy instruction in the code below can be
removed because the cbz jumps to BB1 when x0 is zero :
BB0:
cbz x0, .BB1
BB1:
mov x0, xzr
Jun
Reviewers: gberry, jmolloy, HaoLiu, MatzeB, mcrosier
Subscribers: mcrosier, mssimpso, haicheng, bmakam, llvm-commits, aemerson, rengolin
Differential Revision: http://reviews.llvm.org/D16203
llvm-svn: 261004
2016-02-17 04:02:39 +08:00
|
|
|
; CHECK: cbz x[[REG:[0-9]+]], [[BB:.LBB.*]]
|
|
|
|
; CHECK: [[BB]]:
|
|
|
|
; CHECK-NOT: mov w[[REG]], wzr
|
|
|
|
define i32 @f_XW(i64 %n, i32* nocapture readonly %P) {
|
|
|
|
entry:
|
|
|
|
%tobool = icmp eq i64 %n, 0
|
|
|
|
br i1 %tobool, label %if.end, label %if.then
|
|
|
|
|
|
|
|
if.then: ; preds = %entry
|
|
|
|
%0 = load i32, i32* %P
|
|
|
|
br label %if.end
|
|
|
|
|
|
|
|
if.end: ; preds = %entry, %if.then
|
|
|
|
%a.0 = phi i32 [ %0, %if.then ], [ 0, %entry ]
|
|
|
|
ret i32 %a.0
|
|
|
|
}
|
|
|
|
|
2016-02-18 05:16:53 +08:00
|
|
|
; CHECK-LABEL: f_WX:
|
[AArch64] Add pass to remove redundant copy after RA
Summary:
This change will add a pass to remove unnecessary zero copies in target blocks
of cbz/cbnz instructions. E.g., the copy instruction in the code below can be
removed because the cbz jumps to BB1 when x0 is zero :
BB0:
cbz x0, .BB1
BB1:
mov x0, xzr
Jun
Reviewers: gberry, jmolloy, HaoLiu, MatzeB, mcrosier
Subscribers: mcrosier, mssimpso, haicheng, bmakam, llvm-commits, aemerson, rengolin
Differential Revision: http://reviews.llvm.org/D16203
llvm-svn: 261004
2016-02-17 04:02:39 +08:00
|
|
|
; CHECK: cbz w[[REG:[0-9]+]], [[BB:.LBB.*]]
|
|
|
|
; CHECK: [[BB]]:
|
|
|
|
; CHECK: mov x[[REG]], xzr
|
|
|
|
; Do not remove the mov in this case because we do not know if the upper bits
|
|
|
|
; of the X register are zero.
|
|
|
|
define i64 @f_WX(i32 %n, i64* nocapture readonly %P) {
|
|
|
|
entry:
|
|
|
|
%tobool = icmp eq i32 %n, 0
|
|
|
|
br i1 %tobool, label %if.end, label %if.then
|
|
|
|
|
|
|
|
if.then: ; preds = %entry
|
|
|
|
%0 = load i64, i64* %P
|
|
|
|
br label %if.end
|
|
|
|
|
|
|
|
if.end: ; preds = %entry, %if.then
|
|
|
|
%a.0 = phi i64 [ %0, %if.then ], [ 0, %entry ]
|
|
|
|
ret i64 %a.0
|
|
|
|
}
|
2016-02-18 05:16:53 +08:00
|
|
|
|
|
|
|
; CHECK-LABEL: test_superreg:
|
|
|
|
; CHECK: cbz x[[REG:[0-9]+]], [[BB:.LBB.*]]
|
|
|
|
; CHECK: [[BB]]:
|
|
|
|
; CHECK: str x[[REG]], [x1]
|
|
|
|
; CHECK-NOT: mov w[[REG]], wzr
|
|
|
|
; Because we returned w0 but x0 was marked live-in to the block, we didn't
|
|
|
|
; remove the <kill> on the str leading to a verification failure.
|
|
|
|
define i32 @test_superreg(i64 %in, i64* %dest) {
|
|
|
|
%tst = icmp eq i64 %in, 0
|
|
|
|
br i1 %tst, label %true, label %false
|
|
|
|
|
|
|
|
false:
|
|
|
|
ret i32 42
|
|
|
|
|
|
|
|
true:
|
|
|
|
store volatile i64 %in, i64* %dest
|
|
|
|
ret i32 0
|
2016-02-18 07:07:04 +08:00
|
|
|
}
|