aboutsummaryrefslogtreecommitdiff
path: root/llvm/test/CodeGen/X86/rematerialize-sub-super-reg.mir
blob: b99c5fc8df0cb6d069cf01b4da452a7eb20a88db (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 2
# RUN: llc -mtriple=x86_64-- -run-pass=register-coalescer -o - %s | FileCheck %s

# Test the implicit operands and operand flags on remateralized
# instructions folding into a sub or super register def.

# Test a full register def at %t1 rematerializing into a subregister
# use. The subregister dest operand should be dead, with an
# implicit-def of the full physical register.

---
name: rematerialize_super_register_into_subreg_def
tracksRegLiveness: true
body:             |
  ; CHECK-LABEL: name: rematerialize_super_register_into_subreg_def
  ; CHECK: bb.0:
  ; CHECK-NEXT:   successors: %bb.2(0x40000000), %bb.1(0x40000000)
  ; CHECK-NEXT: {{  $}}
  ; CHECK-NEXT:   %t3:gr64 = MOV64ri32 -11
  ; CHECK-NEXT:   CMP64ri8 %t3, 1, implicit-def $eflags
  ; CHECK-NEXT:   JCC_1 %bb.2, 4, implicit killed $eflags
  ; CHECK-NEXT:   JMP_1 %bb.1
  ; CHECK-NEXT: {{  $}}
  ; CHECK-NEXT: bb.1:
  ; CHECK-NEXT:   successors: %bb.1(0x80000000)
  ; CHECK-NEXT: {{  $}}
  ; CHECK-NEXT:   dead $rax = MOV64ri32 -11, implicit-def $eax
  ; CHECK-NEXT:   CMP64ri8 %t3, 1, implicit-def $eflags
  ; CHECK-NEXT:   JCC_1 %bb.1, 4, implicit killed $eflags
  ; CHECK-NEXT:   RET 0, $eax
  ; CHECK-NEXT: {{  $}}
  ; CHECK-NEXT: bb.2:
  ; CHECK-NEXT:   successors: %bb.3(0x80000000)
  ; CHECK-NEXT: {{  $}}
  ; CHECK-NEXT:   %t3:gr64 = ADD64ri8 %t3, 10, implicit-def $eflags
  ; CHECK-NEXT: {{  $}}
  ; CHECK-NEXT: bb.3:
  ; CHECK-NEXT:   $rax = COPY %t3
  ; CHECK-NEXT:   RET 0, $rax
  bb.0:
    %t1:gr64 = MOV64ri32 -11
    CMP64ri8 %t1, 1, implicit-def $eflags
    JCC_1 %bb.2, 4, implicit killed $eflags
    JMP_1 %bb.1

  bb.1:
    %t2:gr64 = COPY %t1
    $eax = COPY %t2.sub_32bit
    CMP64ri8 %t2, 1, implicit-def $eflags
    JCC_1 %bb.1, 4, implicit killed $eflags
    RET 0, $eax

  bb.2:
    %t3:gr64 = COPY %t1
    %t3:gr64 = ADD64ri8 %t3, 10, implicit-def $eflags

  bb.3:
    $rax = COPY %t3
    RET 0, $rax

...

# Test an undef subregister def of %t1 rematerializing into a physical
# super register def
---
name:            rematerialize_subregister_into_superreg_def
tracksRegLiveness: true
body:             |
  ; CHECK-LABEL: name: rematerialize_subregister_into_superreg_def
  ; CHECK: bb.0:
  ; CHECK-NEXT:   successors: %bb.2(0x40000000), %bb.1(0x40000000)
  ; CHECK-NEXT: {{  $}}
  ; CHECK-NEXT:   undef %t3.sub_32bit:gr64_with_sub_8bit = MOV32ri -11
  ; CHECK-NEXT:   CMP64ri8 %t3, 1, implicit-def $eflags
  ; CHECK-NEXT:   JCC_1 %bb.2, 4, implicit killed $eflags
  ; CHECK-NEXT:   JMP_1 %bb.1
  ; CHECK-NEXT: {{  $}}
  ; CHECK-NEXT: bb.1:
  ; CHECK-NEXT:   successors: %bb.1(0x80000000)
  ; CHECK-NEXT: {{  $}}
  ; CHECK-NEXT:   dead $eax = MOV32ri -11, implicit-def $rax
  ; CHECK-NEXT:   CMP64ri8 %t3, 1, implicit-def $eflags
  ; CHECK-NEXT:   JCC_1 %bb.1, 4, implicit killed $eflags
  ; CHECK-NEXT:   RET 0, $rax
  ; CHECK-NEXT: {{  $}}
  ; CHECK-NEXT: bb.2:
  ; CHECK-NEXT:   successors: %bb.3(0x80000000)
  ; CHECK-NEXT: {{  $}}
  ; CHECK-NEXT:   %t3:gr64_with_sub_8bit = ADD64ri8 %t3, 10, implicit-def $eflags
  ; CHECK-NEXT: {{  $}}
  ; CHECK-NEXT: bb.3:
  ; CHECK-NEXT:   $rax = COPY %t3
  ; CHECK-NEXT:   RET 0, $rax
  bb.0:
    undef %t1.sub_32bit:gr64_with_sub_8bit = MOV32ri -11
    CMP64ri8 %t1, 1, implicit-def $eflags
    JCC_1 %bb.2, 4, implicit killed $eflags
    JMP_1 %bb.1

  bb.1:
    %t2:gr64 = COPY %t1
    $rax = COPY %t2
    CMP64ri8 %t2, 1, implicit-def $eflags
    JCC_1 %bb.1, 4, implicit killed $eflags
    RET 0, $rax

  bb.2:
    %t3:gr64 = COPY %t1
    %t3:gr64 = ADD64ri8 %t3, 10, implicit-def $eflags

  bb.3:
    $rax = COPY %t3
    RET 0, $rax

...

# Handle that rematerializing an instruction with an implicit def of a
# virtual super register into a physical register works.
---
name:            rematerialize_subregister_into_superreg_def_with_impdef_physreg
tracksRegLiveness: true
body:             |
  ; CHECK-LABEL: name: rematerialize_subregister_into_superreg_def_with_impdef_physreg
  ; CHECK: bb.0:
  ; CHECK-NEXT:   successors: %bb.2(0x40000000), %bb.1(0x40000000)
  ; CHECK-NEXT: {{  $}}
  ; CHECK-NEXT:   undef %t3.sub_32bit:gr64_with_sub_8bit = MOV32ri -11, implicit-def %t3
  ; CHECK-NEXT:   CMP64ri8 %t3, 1, implicit-def $eflags
  ; CHECK-NEXT:   JCC_1 %bb.2, 4, implicit killed $eflags
  ; CHECK-NEXT:   JMP_1 %bb.1
  ; CHECK-NEXT: {{  $}}
  ; CHECK-NEXT: bb.1:
  ; CHECK-NEXT:   successors: %bb.1(0x80000000)
  ; CHECK-NEXT: {{  $}}
  ; CHECK-NEXT:   dead $eax = MOV32ri -11, implicit-def $rax
  ; CHECK-NEXT:   CMP64ri8 %t3, 1, implicit-def $eflags
  ; CHECK-NEXT:   JCC_1 %bb.1, 4, implicit killed $eflags
  ; CHECK-NEXT:   RET 0, $rax
  ; CHECK-NEXT: {{  $}}
  ; CHECK-NEXT: bb.2:
  ; CHECK-NEXT:   successors: %bb.3(0x80000000)
  ; CHECK-NEXT: {{  $}}
  ; CHECK-NEXT:   %t3:gr64_with_sub_8bit = ADD64ri8 %t3, 10, implicit-def $eflags
  ; CHECK-NEXT: {{  $}}
  ; CHECK-NEXT: bb.3:
  ; CHECK-NEXT:   $rax = COPY %t3
  ; CHECK-NEXT:   RET 0, $rax
  bb.0:
    undef %t1.sub_32bit:gr64_with_sub_8bit = MOV32ri -11, implicit-def %t1
    CMP64ri8 %t1, 1, implicit-def $eflags
    JCC_1 %bb.2, 4, implicit killed $eflags
    JMP_1 %bb.1

  bb.1:
    %t2:gr64 = COPY %t1
    $rax = COPY %t2
    CMP64ri8 %t2, 1, implicit-def $eflags
    JCC_1 %bb.1, 4, implicit killed $eflags
    RET 0, $rax

  bb.2:
    %t3:gr64 = COPY %t1
    %t3:gr64 = ADD64ri8 %t3, 10, implicit-def $eflags

  bb.3:
    $rax = COPY %t3
    RET 0, $rax

...