xref: /llvm-project/llvm/test/CodeGen/AArch64/redundant-orrwrs-from-zero-extend.mir (revision a502436259307f95e9c95437d8a1d2d07294341c)
1# RUN: llc -mtriple=aarch64 -run-pass aarch64-mi-peephole-opt -verify-machineinstrs -o - %s | FileCheck %s
2---
3name:            test1
4# CHECK-LABEL: name: test1
5alignment:       4
6tracksRegLiveness: true
7registers:
8  - { id: 0, class: gpr32 }
9  - { id: 1, class: gpr32 }
10  - { id: 2, class: gpr32 }
11  - { id: 3, class: gpr32 }
12  - { id: 4, class: gpr64 }
13body:             |
14  bb.0:
15    liveins: $w0, $w1
16
17    %0:gpr32 = COPY $w0
18    %1:gpr32 = COPY $w1
19    B %bb.1
20
21  bb.1:
22    %2:gpr32 = nsw ADDWrr %0, %1
23    B %bb.2
24
25  bb.2:
26    ; CHECK-LABEL: bb.2:
27    ; CHECK-NOT: %3:gpr32 = ORRWrs $wzr, %2, 0
28    ; The ORRWrs should be removed.
29    %3:gpr32 = ORRWrs $wzr, %2, 0
30    %4:gpr64 = SUBREG_TO_REG 0, %3, %subreg.sub_32
31    B %bb.3
32
33  bb.3:
34    $x0 = COPY %4
35    RET_ReallyLR implicit $x0
36...
37---
38name:            test2
39# CHECK-LABEL: name: test2
40alignment:       4
41tracksRegLiveness: true
42registers:
43  - { id: 0, class: gpr64 }
44  - { id: 1, class: gpr32 }
45  - { id: 2, class: gpr32 }
46  - { id: 3, class: gpr64 }
47body:             |
48  bb.0:
49    liveins: $x0
50
51    %0:gpr64 = COPY $x0
52    B %bb.1
53
54  bb.1:
55    %1:gpr32 = EXTRACT_SUBREG %0, %subreg.sub_32
56    B %bb.2
57
58  bb.2:
59    ; CHECK-LABEL: bb.2:
60    ; CHECK: %2:gpr32 = ORRWrs $wzr, %1, 0
61    ; The ORRWrs should not be removed.
62    %2:gpr32 = ORRWrs $wzr, %1, 0
63    %3:gpr64 = SUBREG_TO_REG 0, %2, %subreg.sub_32
64    B %bb.3
65
66  bb.3:
67    $x0 = COPY %3
68    RET_ReallyLR implicit $x0
69...
70