1 # RUN: llc -mtriple=i686-- -run-pass machine-cp -verify-machineinstrs -o - %s | FileCheck %s
5 define void @copyprop_remove_kill0() { ret void }
6 define void @copyprop_remove_kill1() { ret void }
7 define void @copyprop_remove_kill2() { ret void }
8 define void @copyprop0() { ret void }
9 define void @copyprop1() { ret void }
10 define void @copyprop2() { ret void }
11 define void @nocopyprop0() { ret void }
12 define void @nocopyprop1() { ret void }
13 define void @nocopyprop2() { ret void }
14 define void @nocopyprop3() { ret void }
15 define void @nocopyprop4() { ret void }
16 define void @nocopyprop5() { ret void }
19 # The second copy is redundant and will be removed, check that we also remove
20 # the kill flag of intermediate instructions.
21 # CHECK-LABEL: name: copyprop_remove_kill0
23 # CHECK-NEXT: $rax = COPY $rdi
24 # CHECK-NEXT: NOOP implicit $rdi
26 # CHECK-NEXT: NOOP implicit $rax, implicit $rdi
27 name: copyprop_remove_kill0
31 NOOP implicit killed $rdi
33 NOOP implicit $rax, implicit $rdi
36 # The second copy is redundant and will be removed, check that we also remove
37 # the kill flag of intermediate instructions.
38 # CHECK-LABEL: name: copyprop_remove_kill1
40 # CHECK-NEXT: $rax = COPY $rdi
41 # CHECK-NEXT: NOOP implicit $edi
43 # CHECK-NEXT: NOOP implicit $rax, implicit $rdi
44 name: copyprop_remove_kill1
48 NOOP implicit killed $edi
50 NOOP implicit $rax, implicit $rdi
53 # The second copy is redundant and will be removed, check that we also remove
54 # the kill flag of intermediate instructions.
55 # CHECK-LABEL: name: copyprop_remove_kill2
57 # CHECK-NEXT: $ax = COPY $di
58 # CHECK-NEXT: NOOP implicit $rdi
60 # CHECK-NEXT: NOOP implicit $rax, implicit $rdi
61 name: copyprop_remove_kill2
65 NOOP implicit killed $rdi
67 NOOP implicit $rax, implicit $rdi
70 # The second copy is redundant; the call preserves the source and dest register.
71 # CHECK-LABEL: name: copyprop0
73 # CHECK-NEXT: $rax = COPY $rdi
74 # CHECK-NEXT: CALL64pcrel32 @foo, csr_64_rt_mostregs
75 # CHECK-NEXT: NOOP implicit $edi
77 # CHECK-NEXT: NOOP implicit $rax, implicit $rdi
82 CALL64pcrel32 @foo, csr_64_rt_mostregs
83 NOOP implicit killed $edi
85 NOOP implicit $rax, implicit $rdi
88 # The 2nd copy is redundant; The call preserves the source and dest register.
89 # CHECK-LABEL: name: copyprop1
91 # CHECK-NEXT: $rax = COPY $rdi
92 # CHECK-NEXT: NOOP implicit $rax
93 # CHECK-NEXT: NOOP implicit $rax, implicit $rdi
98 NOOP implicit killed $rax
100 NOOP implicit $rax, implicit $rdi
103 # CHECK-LABEL: name: copyprop2
105 # CHECK-NEXT: $rax = COPY $rdi
106 # CHECK-NEXT: NOOP implicit $ax
107 # CHECK-NEXT: CALL64pcrel32 @foo, csr_64_rt_mostregs
108 # CHECK-NOT: $rax = COPY $rdi
109 # CHECK-NEXT: NOOP implicit $rax, implicit $rdi
114 NOOP implicit killed $ax
115 CALL64pcrel32 @foo, csr_64_rt_mostregs
117 NOOP implicit $rax, implicit $rdi
120 # The second copy is not redundant if the source register ($rax) is clobbered
121 # even if the dest ($rbp) is not.
122 # CHECK-LABEL: name: nocopyprop0
124 # CHECK-NEXT: $rax = COPY $rbp
125 # CHECK-NEXT: CALL64pcrel32 @foo, csr_64, implicit $rax, implicit $rbp
126 # CHECK-NEXT: $rbp = COPY $rax
127 # CHECK-NEXT: NOOP implicit $rax, implicit $rbp
132 CALL64pcrel32 @foo, csr_64, implicit $rax, implicit $rbp
134 NOOP implicit $rax, implicit $rbp
137 # The second copy is not redundant if the dest register ($rax) is clobbered
138 # even if the source ($rbp) is not.
139 # CHECK-LABEL: name: nocopyprop1
141 # CHECK-NEXT: $rbp = COPY $rax
142 # CHECK-NEXT: CALL64pcrel32 @foo, csr_64, implicit $rax, implicit $rbp
143 # CHECK-NEXT: $rax = COPY $rbp
144 # CHECK-NEXT: NOOP implicit $rax, implicit $rbp
149 CALL64pcrel32 @foo, csr_64, implicit $rax, implicit $rbp
151 NOOP implicit $rax, implicit $rbp
154 # The second copy is not redundant if the source register ($rax) is clobbered
155 # even if the dest ($rbp) is not.
156 # CHECK-LABEL: name: nocopyprop2
158 # CHECK-NEXT: $rax = COPY $rbp
159 # CHECK-NEXT: CALL64pcrel32 @foo, csr_64, implicit $rax, implicit $rbp
160 # CHECK-NEXT: $rax = COPY $rbp
161 # CHECK-NEXT: NOOP implicit $rax, implicit $rbp
166 CALL64pcrel32 @foo, csr_64, implicit $rax, implicit $rbp
168 NOOP implicit $rax, implicit $rbp
171 # The second copy is not redundant if the dest register ($rax) is clobbered
172 # even if the source ($rbp) is not.
173 # CHECK-LABEL: name: nocopyprop3
175 # CHECK-NEXT: $rbp = COPY $rax
176 # CHECK-NEXT: CALL64pcrel32 @foo, csr_64, implicit $rax, implicit $rbp
177 # CHECK-NEXT: $rbp = COPY $rax
178 # CHECK-NEXT: NOOP implicit $rax, implicit $rbp
183 CALL64pcrel32 @foo, csr_64, implicit $rax, implicit $rbp
185 NOOP implicit $rax, implicit $rbp
188 # A reserved register may change its value so the 2nd copy is not redundant.
189 # CHECK-LABEL: name: nocopyprop4
191 # CHECK-NEXT: $rax = COPY $rip
192 # CHECK-NEXT: NOOP implicit $rax
193 # CHECK-NEXT: $rax = COPY $rip
194 # CHECK-NEXT: NOOP implicit $rax
204 # Writing to a reserved register may have additional effects (slightly illegal
205 # testcase because writing to $rip like this should make the instruction a jump)
206 # CHECK-LABEL: name: nocopyprop5
208 # CHECK-NEXT: $rip = COPY $rax
209 # CHECK-NEXT: $rip = COPY $rax