1 # RUN: llc -mtriple=aarch64-linux-gnu -run-pass machine-cp -mcp-use-is-copy-instr -o - %s | FileCheck %s
2 # Tests for MachineCopyPropagation copy forwarding.
5 # CHECK-LABEL: name: test1
6 # CHECK: $x0 = SUBXri $x0, 1, 0
8 tracksRegLiveness: true
12 renamable $x1 = COPY $x0
13 $x0 = SUBXri renamable $x1, 1, 0
16 # Don't forward if not renamable.
17 # CHECK-LABEL: name: test2
18 # CHECK: $x0 = SUBXri $x1, 1, 0
20 tracksRegLiveness: true
25 $x0 = SUBXri $x1, 1, 0
28 # Don't forward reserved non-constant reg values.
29 # CHECK-LABEL: name: test4
30 # CHECK: $x0 = SUBXri renamable $x1, 1, 0
32 tracksRegLiveness: true
36 $sp = SUBXri $sp, 16, 0
37 renamable $x1 = COPY $sp
38 $x0 = SUBXri renamable $x1, 1, 0
39 $sp = ADDXri $sp, 16, 0
42 # Don't violate opcode constraints when forwarding.
43 # CHECK-LABEL: name: test5
44 # CHECK: $x0 = SUBXri renamable $x1, 1, 0
46 tracksRegLiveness: true
50 renamable $x1 = COPY $xzr
51 $x0 = SUBXri renamable $x1, 1, 0
54 # Test cross-class COPY forwarding.
55 # CHECK-LABEL: name: test6
56 # CHECK: $x2 = COPY $x0
58 tracksRegLiveness: true
62 renamable $d1 = COPY $x0
63 $x2 = COPY renamable $d1
64 RET_ReallyLR implicit $x2
67 # Don't forward if there are overlapping implicit operands.
68 # CHECK-LABEL: name: test7
69 # CHECK: $w0 = SUBWri killed renamable $w1, 1, 0
71 tracksRegLiveness: true
75 renamable $w1 = COPY $w0
76 $w0 = SUBWri killed renamable $w1, 1, 0, implicit killed $x1
79 # Check that kill flags are cleared.
80 # CHECK-LABEL: name: test8
81 # CHECK: $x2 = ADDXri $x0, 1, 0
82 # CHECK: $x0 = SUBXri $x0, 1, 0
84 tracksRegLiveness: true
88 renamable $x1 = COPY $x0
89 $x2 = ADDXri killed $x0, 1, 0
90 $x0 = SUBXri renamable $x1, 1, 0
93 # Don't forward if value is clobbered.
94 # CHECK-LABEL: name: test9
95 # CHECK: $x2 = SUBXri renamable $x1, 1, 0
97 tracksRegLiveness: true
101 renamable $x1 = COPY $x0
102 $x0 = ADDXri $x0, 1, 0
103 $x2 = SUBXri renamable $x1, 1, 0
106 # CHECK-LABEL: name: test1_orr_as_copy
107 # CHECK: STRBBui $wzr, killed renamable $x8, 36
108 name: test1_orr_as_copy
109 tracksRegLiveness: true
113 $w9 = ORRWrs $wzr, $wzr, 0
114 STRBBui killed renamable $w9, killed renamable $x8, 36