Skip to content

Commit 1a95dc6

Browse files
committed
Get rid of REMAT_NO_USES heuristic
It just complicated the code and mostly made things worse; its intentions are better served by the hinting and neighbor spilling logic.
1 parent 2b4758c commit 1a95dc6

File tree

10 files changed

+5160
-5176
lines changed

10 files changed

+5160
-5176
lines changed

crates/codegen/src/regalloc/assign.rs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -127,17 +127,6 @@ impl<M: MachineRegalloc> RegAllocContext<'_, M> {
127127
probe_order: &mut ProbeOrder,
128128
fragment: LiveSetFragment,
129129
) -> Result<(), RegallocError> {
130-
if self.live_set_fragments[fragment]
131-
.flags
132-
.contains(LiveSetFragmentFlags::REMAT_NO_USES)
133-
{
134-
// Don't even bother if a rematerializable range contains no uses - splitting should
135-
// already have carved out the interesting portions of the original live set, so just
136-
// let the value be rematerialized there.
137-
self.spill_fragment_and_neighbors(fragment);
138-
return Ok(());
139-
}
140-
141130
let live_set = self.live_set_fragments[fragment].live_set;
142131
let class = self.live_sets[live_set].class;
143132

crates/codegen/src/regalloc/fragment.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,6 @@ impl<M: MachineRegalloc> RegAllocContext<'_, M> {
119119
all_ranges_remat,
120120
);
121121

122-
fragment_data
123-
.flags
124-
.set(LiveSetFragmentFlags::REMAT_NO_USES, remat_no_uses);
125-
126122
fragment_data.spill_weight = if is_atomic {
127123
ATOMIC_FRAGMENT_WEIGHT
128124
} else {

crates/codegen/src/regalloc/types.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,6 @@ bitflags! {
360360
const ATOMIC = 0b0001;
361361
const SPILLED = 0b0010;
362362
const COMPLETELY_REMATTABLE = 0b0100;
363-
const REMAT_NO_USES = 0b1000;
364363
}
365364
}
366365

crates/filetests/cases/codegen/tdn/array_jagged.spdr

Lines changed: 72 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ func @"System.Int32 Tests.CodeGenBringUpTests::ArrayJagged(System.Int32)":i32(i3
7171
# nextln: 000083: 89 19 mov dword ptr [rcx], ebx
7272
# nextln: 000085: 8b 09 mov ecx, dword ptr [rcx]
7373
# nextln: 000087: 4c 3b e9 cmp r13, rcx
74-
# nextln: 00008a: 0f 8d 2f 01 00 00 jge 0x1bf
74+
# nextln: 00008a: 0f 8d 2c 01 00 00 jge 0x1bc
7575
# nextln: 000090: b9 04 00 00 00 mov ecx, 4
7676
# nextln: 000095: 48 89 cf mov rdi, rcx
7777
# nextln: 000098: 49 0f af fd imul rdi, r13
@@ -88,78 +88,78 @@ func @"System.Int32 Tests.CodeGenBringUpTests::ArrayJagged(System.Int32)":i32(i3
8888
# nextln: 0000c1: 33 ff xor edi, edi
8989
# nextln: 0000c3: 4c 63 e7 movsxd r12, edi
9090
# nextln: 0000c6: 4c 3b e2 cmp r12, rdx
91-
# nextln: 0000c9: 0f 8d f0 00 00 00 jge 0x1bf
92-
# nextln: 0000cf: 48 89 ca mov rdx, rcx
93-
# nextln: 0000d2: 49 0f af d4 imul rdx, r12
94-
# nextln: 0000d6: b9 18 00 00 00 mov ecx, 0x18
95-
# nextln: 0000db: 48 03 ca add rcx, rdx
96-
# nextln: 0000de: 4c 03 f1 add r14, rcx
91+
# nextln: 0000c9: 0f 8d ed 00 00 00 jge 0x1bc
92+
# nextln: 0000cf: 48 89 cf mov rdi, rcx
93+
# nextln: 0000d2: 49 0f af fc imul rdi, r12
94+
# nextln: 0000d6: ba 18 00 00 00 mov edx, 0x18
95+
# nextln: 0000db: 48 03 d7 add rdx, rdi
96+
# nextln: 0000de: 4c 03 f2 add r14, rdx
9797
# nextln: 0000e1: 49 89 06 mov qword ptr [r14], rax
98-
# nextln: 0000e4: 41 be 08 00 00 00 mov r14d, 8
99-
# nextln: 0000ea: 4c 8b 3c 24 mov r15, qword ptr [rsp]
100-
# nextln: 0000ee: bf aa 00 00 00 mov edi, 0xaa
101-
# nextln: 0000f3: e8 00 00 00 00 call 0xf8 # RELOC_PC32 -> @gc_new + -4
102-
# nextln: 0000f8: 48 89 c7 mov rdi, rax
103-
# nextln: 0000fb: 48 83 c7 10 add rdi, 0x10
104-
# nextln: 0000ff: 89 1f mov dword ptr [rdi], ebx
105-
# nextln: 000101: 8b 0f mov ecx, dword ptr [rdi]
106-
# nextln: 000103: 4c 3b e1 cmp r12, rcx
107-
# nextln: 000106: 0f 8d b3 00 00 00 jge 0x1bf
108-
# nextln: 00010c: b9 04 00 00 00 mov ecx, 4
109-
# nextln: 000111: 49 89 c8 mov r8, rcx
110-
# nextln: 000114: 4d 0f af c4 imul r8, r12
111-
# nextln: 000118: ba 14 00 00 00 mov edx, 0x14
112-
# nextln: 00011d: 48 89 d6 mov rsi, rdx
113-
# nextln: 000120: 49 03 f0 add rsi, r8
114-
# nextln: 000123: 49 89 c0 mov r8, rax
115-
# nextln: 000126: 4c 03 c6 add r8, rsi
116-
# nextln: 000129: be 02 00 00 00 mov esi, 2
117-
# nextln: 00012e: 41 89 30 mov dword ptr [r8], esi
118-
# nextln: 000131: 8b 3f mov edi, dword ptr [rdi]
119-
# nextln: 000133: 4c 3b ef cmp r13, rdi
120-
# nextln: 000136: 0f 8d 83 00 00 00 jge 0x1bf
121-
# nextln: 00013c: 4c 89 ff mov rdi, r15
122-
# nextln: 00013f: 48 83 c7 10 add rdi, 0x10
123-
# nextln: 000143: 48 89 c6 mov rsi, rax
124-
# nextln: 000146: 48 03 74 24 10 add rsi, qword ptr [rsp + 0x10]
125-
# nextln: 00014b: 41 b8 03 00 00 00 mov r8d, 3
126-
# nextln: 000151: 44 89 06 mov dword ptr [rsi], r8d
127-
# nextln: 000154: 8b 3f mov edi, dword ptr [rdi]
128-
# nextln: 000156: 4c 3b ef cmp r13, rdi
129-
# nextln: 000159: 0f 8d 60 00 00 00 jge 0x1bf
130-
# nextln: 00015f: 4d 0f af f5 imul r14, r13
131-
# nextln: 000163: bf 18 00 00 00 mov edi, 0x18
132-
# nextln: 000168: 49 03 fe add rdi, r14
133-
# nextln: 00016b: 4c 03 ff add r15, rdi
134-
# nextln: 00016e: 49 89 07 mov qword ptr [r15], rax
135-
# nextln: 000171: 48 8b 04 24 mov rax, qword ptr [rsp]
136-
# nextln: 000175: 48 89 c6 mov rsi, rax
137-
# nextln: 000178: 48 83 c6 10 add rsi, 0x10
138-
# nextln: 00017c: 8b 36 mov esi, dword ptr [rsi]
139-
# nextln: 00017e: 4c 3b ee cmp r13, rsi
140-
# nextln: 000181: 0f 8d 38 00 00 00 jge 0x1bf
141-
# nextln: 000187: 48 03 c7 add rax, rdi
142-
# nextln: 00018a: 48 8b 00 mov rax, qword ptr [rax]
143-
# nextln: 00018d: 48 89 c7 mov rdi, rax
144-
# nextln: 000190: 48 83 c7 10 add rdi, 0x10
145-
# nextln: 000194: 8b 37 mov esi, dword ptr [rdi]
146-
# nextln: 000196: 48 63 7c 24 08 movsxd rdi, dword ptr [rsp + 8]
147-
# nextln: 00019b: 48 3b fe cmp rdi, rsi
148-
# nextln: 00019e: 0f 8d 1b 00 00 00 jge 0x1bf
149-
# nextln: 0001a4: 48 0f af cf imul rcx, rdi
150-
# nextln: 0001a8: 48 03 d1 add rdx, rcx
151-
# nextln: 0001ab: 48 03 c2 add rax, rdx
152-
# nextln: 0001ae: 8b 00 mov eax, dword ptr [rax]
153-
# nextln: 0001b0: 48 83 c4 28 add rsp, 0x28
154-
# nextln: 0001b4: 5b pop rbx
155-
# nextln: 0001b5: 41 5c pop r12
156-
# nextln: 0001b7: 41 5d pop r13
157-
# nextln: 0001b9: 41 5e pop r14
158-
# nextln: 0001bb: 41 5f pop r15
159-
# nextln: 0001bd: 5d pop rbp
160-
# nextln: 0001be: c3 ret
161-
# nextln: 0001bf: e8 00 00 00 00 call 0x1c4 # RELOC_PC32 -> @throw_index_out_of_range_exception + -4
162-
# nextln: 0001c4: 0f 0b ud2
98+
# nextln: 0000e4: 49 89 ce mov r14, rcx
99+
# nextln: 0000e7: 4c 8b 3c 24 mov r15, qword ptr [rsp]
100+
# nextln: 0000eb: bf aa 00 00 00 mov edi, 0xaa
101+
# nextln: 0000f0: e8 00 00 00 00 call 0xf5 # RELOC_PC32 -> @gc_new + -4
102+
# nextln: 0000f5: 48 89 c7 mov rdi, rax
103+
# nextln: 0000f8: 48 83 c7 10 add rdi, 0x10
104+
# nextln: 0000fc: 89 1f mov dword ptr [rdi], ebx
105+
# nextln: 0000fe: 8b 0f mov ecx, dword ptr [rdi]
106+
# nextln: 000100: 4c 3b e1 cmp r12, rcx
107+
# nextln: 000103: 0f 8d b3 00 00 00 jge 0x1bc
108+
# nextln: 000109: b9 04 00 00 00 mov ecx, 4
109+
# nextln: 00010e: 49 89 c8 mov r8, rcx
110+
# nextln: 000111: 4d 0f af c4 imul r8, r12
111+
# nextln: 000115: ba 14 00 00 00 mov edx, 0x14
112+
# nextln: 00011a: 48 89 d6 mov rsi, rdx
113+
# nextln: 00011d: 49 03 f0 add rsi, r8
114+
# nextln: 000120: 49 89 c0 mov r8, rax
115+
# nextln: 000123: 4c 03 c6 add r8, rsi
116+
# nextln: 000126: be 02 00 00 00 mov esi, 2
117+
# nextln: 00012b: 41 89 30 mov dword ptr [r8], esi
118+
# nextln: 00012e: 8b 3f mov edi, dword ptr [rdi]
119+
# nextln: 000130: 4c 3b ef cmp r13, rdi
120+
# nextln: 000133: 0f 8d 83 00 00 00 jge 0x1bc
121+
# nextln: 000139: 4c 89 ff mov rdi, r15
122+
# nextln: 00013c: 48 83 c7 10 add rdi, 0x10
123+
# nextln: 000140: 48 89 c6 mov rsi, rax
124+
# nextln: 000143: 48 03 74 24 10 add rsi, qword ptr [rsp + 0x10]
125+
# nextln: 000148: 41 b8 03 00 00 00 mov r8d, 3
126+
# nextln: 00014e: 44 89 06 mov dword ptr [rsi], r8d
127+
# nextln: 000151: 8b 3f mov edi, dword ptr [rdi]
128+
# nextln: 000153: 4c 3b ef cmp r13, rdi
129+
# nextln: 000156: 0f 8d 60 00 00 00 jge 0x1bc
130+
# nextln: 00015c: 4d 0f af f5 imul r14, r13
131+
# nextln: 000160: bf 18 00 00 00 mov edi, 0x18
132+
# nextln: 000165: 49 03 fe add rdi, r14
133+
# nextln: 000168: 4c 03 ff add r15, rdi
134+
# nextln: 00016b: 49 89 07 mov qword ptr [r15], rax
135+
# nextln: 00016e: 48 8b 04 24 mov rax, qword ptr [rsp]
136+
# nextln: 000172: 48 89 c6 mov rsi, rax
137+
# nextln: 000175: 48 83 c6 10 add rsi, 0x10
138+
# nextln: 000179: 8b 36 mov esi, dword ptr [rsi]
139+
# nextln: 00017b: 4c 3b ee cmp r13, rsi
140+
# nextln: 00017e: 0f 8d 38 00 00 00 jge 0x1bc
141+
# nextln: 000184: 48 03 c7 add rax, rdi
142+
# nextln: 000187: 48 8b 00 mov rax, qword ptr [rax]
143+
# nextln: 00018a: 48 89 c7 mov rdi, rax
144+
# nextln: 00018d: 48 83 c7 10 add rdi, 0x10
145+
# nextln: 000191: 8b 37 mov esi, dword ptr [rdi]
146+
# nextln: 000193: 48 63 7c 24 08 movsxd rdi, dword ptr [rsp + 8]
147+
# nextln: 000198: 48 3b fe cmp rdi, rsi
148+
# nextln: 00019b: 0f 8d 1b 00 00 00 jge 0x1bc
149+
# nextln: 0001a1: 48 0f af cf imul rcx, rdi
150+
# nextln: 0001a5: 48 03 d1 add rdx, rcx
151+
# nextln: 0001a8: 48 03 c2 add rax, rdx
152+
# nextln: 0001ab: 8b 00 mov eax, dword ptr [rax]
153+
# nextln: 0001ad: 48 83 c4 28 add rsp, 0x28
154+
# nextln: 0001b1: 5b pop rbx
155+
# nextln: 0001b2: 41 5c pop r12
156+
# nextln: 0001b4: 41 5d pop r13
157+
# nextln: 0001b6: 41 5e pop r14
158+
# nextln: 0001b8: 41 5f pop r15
159+
# nextln: 0001ba: 5d pop rbp
160+
# nextln: 0001bb: c3 ret
161+
# nextln: 0001bc: e8 00 00 00 00 call 0x1c1 # RELOC_PC32 -> @throw_index_out_of_range_exception + -4
162+
# nextln: 0001c1: 0f 0b ud2
163163

164164
%0:ctrl, %1:i32 = entry
165165
%2:ctrl, %3:phisel = region %0

0 commit comments

Comments
 (0)