1; RUN: llc < %s -mtriple=aarch64-apple-ios -fast-isel -verify-machineinstrs | FileCheck %s
2
3; Check that the kill flag is cleared between CSE'd instructions on their
4; imp-def'd registers.
5; The verifier would complain otherwise.
6define i64 @csed-impdef-killflag(i64 %a) {
7; CHECK-LABEL: csed-impdef-killflag
8; CHECK-DAG:  mov    [[REG0:w[0-9]+]], wzr
9; CHECK-DAG:  orr    [[REG1:w[0-9]+]], wzr, #0x1
10; CHECK-DAG:  orr    [[REG2:x[0-9]+]], xzr, #0x2
11; CHECK-DAG:  orr    [[REG3:x[0-9]+]], xzr, #0x3
12; CHECK:      cmp    x0, #0
13; CHECK-DAG:  csel   w[[SELECT_WREG_1:[0-9]+]], [[REG0]], [[REG1]], ne
14; CHECK-DAG:  csel   [[SELECT_XREG_2:x[0-9]+]], [[REG2]], [[REG3]], ne
15; CHECK:      ubfx   [[SELECT_XREG_1:x[0-9]+]], x[[SELECT_WREG_1]], #0, #32
16; CHECK-NEXT: add    x0, [[SELECT_XREG_2]], [[SELECT_XREG_1]]
17; CHECK-NEXT: ret
18
19  %1 = icmp ne i64 %a, 0
20  %2 = select i1 %1, i32 0, i32 1
21  %3 = icmp ne i64 %a, 0
22  %4 = select i1 %3, i64 2, i64 3
23  %5 = zext i32 %2 to i64
24  %6 = add i64 %4, %5
25  ret i64 %6
26}
27