xref: /llvm-project/llvm/test/CodeGen/X86/coalescer-partial-redundancy-clear-dead-flag-undef-copy.mir (revision 538a83e4b9ddaa6cc9e8680fa97b2e33cd03192d)
1# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 4
2# RUN: llc -mtriple=x86_64-pc-linux-gnu -run-pass=register-coalescer -verify-coalescing -o - %s | FileCheck %s
3
4# Check for "Live range continues after dead def flag".
5
6# There are 2 copies of undef, but the registers also appear to be
7# live due to block live outs, and thus were not deleted as
8# eliminateUndefCopy only considered the live range, and not the undef
9# flag.
10#
11# removePartialRedundancy would move the COPY undef %0 in bb.1 to
12# bb.0.  The live range of %1 would then be extended to be live out of
13# %bb.1 for the backedge phi. This would then fail the verifier, since
14# the dead flag was no longer valid. This was fixed by directly
15# considering the undef flag to avoid considering this special case.
16
17---
18name: partial_redundancy_coalesce_undef_copy_live_out
19tracksRegLiveness: true
20body:             |
21  ; CHECK-LABEL: name: partial_redundancy_coalesce_undef_copy_live_out
22  ; CHECK: bb.0:
23  ; CHECK-NEXT:   successors: %bb.1(0x80000000)
24  ; CHECK-NEXT:   liveins: $rdi
25  ; CHECK-NEXT: {{  $}}
26  ; CHECK-NEXT:   [[COPY:%[0-9]+]]:gr32 = COPY $rdi
27  ; CHECK-NEXT: {{  $}}
28  ; CHECK-NEXT: bb.1:
29  ; CHECK-NEXT:   successors: %bb.1(0x80000000)
30  ; CHECK-NEXT: {{  $}}
31  ; CHECK-NEXT:   dead [[XOR32ri:%[0-9]+]]:gr32 = XOR32ri undef [[XOR32ri]], 1, implicit-def dead $eflags
32  ; CHECK-NEXT:   dead [[MOV32rr:%[0-9]+]]:gr32 = MOV32rr [[COPY]]
33  ; CHECK-NEXT:   [[COPY:%[0-9]+]]:gr32 = IMPLICIT_DEF
34  ; CHECK-NEXT:   JMP_1 %bb.1
35  bb.0:
36    liveins: $rdi
37
38    %0:gr32 = COPY $rdi
39
40  bb.1:
41    %1:gr32 = COPY undef %0
42    dead %1:gr32 = XOR32ri %1, 1, implicit-def dead $eflags
43    dead %2:gr32 = MOV32rr killed %0
44    %0:gr32 = COPY killed undef %1
45    JMP_1 %bb.1
46
47...
48