Change ir_allocate_blocked_reg() according to description from "Optimized Interval Splitting in a Linear Scan Register Allocator"

This commit is contained in:
Dmitry Stogov 2023-06-28 22:00:50 +03:00
parent b1e6ae66e3
commit 2bfe1626ad
5 changed files with 100 additions and 101 deletions

View File

@ -2901,7 +2901,7 @@ static ir_reg ir_allocate_blocked_reg(ir_ctx *ctx, ir_live_interval *ival, ir_li
blockPos[reg] = nextUsePos[reg] = 0;
} else {
pos = ir_first_use_pos_after(other, ival->range.start,
IR_USE_MUST_BE_IN_REG /* | IR_USE_SHOULD_BE_IN_REG */); // TODO: ???
IR_USE_MUST_BE_IN_REG | IR_USE_SHOULD_BE_IN_REG);
if (pos < nextUsePos[reg]) {
nextUsePos[reg] = pos;
}
@ -2950,7 +2950,7 @@ static ir_reg ir_allocate_blocked_reg(ir_ctx *ctx, ir_live_interval *ival, ir_li
}
} else {
pos = ir_first_use_pos_after(other, ival->range.start,
IR_USE_MUST_BE_IN_REG /* | IR_USE_SHOULD_BE_IN_REG */); // TODO: ???
IR_USE_MUST_BE_IN_REG | IR_USE_SHOULD_BE_IN_REG);
if (pos < nextUsePos[reg]) {
nextUsePos[reg] = pos;
}

View File

@ -115,22 +115,22 @@ R3 (d_5) [SPILL=0x8]
[%xmm1]: [5.0-10.2), DEF(5.0, hint=R2)!
: [10.2-24.0), [26.0-29.0), [31.0-34.0)
: [34.0-38.0), USE(34.1/2)
R4 (d_12, d_36) [%xmm1]: [11.0-24.0), [26.0-29.0), [31.0-32.0), [36.0-38.0), DEF(12.2), USE(20.0/1, hint=R8)!, USE(20.0/2), USE(32.0/1)!, DEF(36.0, hint=R12)!, PHI_USE(37.2, phi=d_12/3)
R5 (d_13, d_34) [SPILL=0x10]
R4 (d_12, d_36) [SPILL=0x10]
[%xmm1]: [11.0-20.0), DEF(12.2), USE(20.0/1, hint=R8)!, USE(20.0/2)
: [20.0-24.0), [26.0-29.0), [31.0-31.3)
[%xmm1]: [31.3-32.0), [36.0-38.0), USE(32.0/1)!, DEF(36.0, hint=R12)!, PHI_USE(37.2, phi=d_12/3)
R5 (d_13, d_34) [SPILL=0x18]
[%xmm0]: [11.0-18.0), DEF(13.2), USE(18.0/1, hint=R7)!, USE(18.0/2)
: [18.0-24.0), [26.0-29.0), [31.0-32.0)
[%xmm0]: [32.0-32.1), [34.0-38.0), USE(32.1/2, hint=R10), DEF(34.0, hint=R11)!, PHI_USE(37.2, phi=d_13/3)
: [32.0-32.1), USE(32.1/2, hint=R10)
[%xmm0]: [34.0-38.0), DEF(34.0, hint=R11)!, PHI_USE(37.2, phi=d_13/3)
R6 (d_14, d_15) [%eax]: [11.0-15.1), [15.2-25.0), [26.0-29.0), [31.0-38.0), DEF(14.2), USE(15.1/1)!, DEF(15.2)!, USE(25.0/2, hint=%eax), USE(28.1/27.1), PHI_USE(37.2, phi=d_14/3)
R7 (d_18) [SPILL=0x18]
[%xmm0]: [18.0-20.0), DEF(18.0, hint=R5)!
: [20.0-21.0)
: [21.0-24.0), [26.0-29.0), [31.0-32.3), USE(21.1/2)
[%xmm0]: [32.3-33.0), USE(33.0/1, hint=R11)!
R7 (d_18) [%xmm0]: [18.0-24.0), [26.0-29.0), [31.0-33.0), DEF(18.0, hint=R5)!, USE(21.1/2), USE(33.0/1, hint=R11)!
R8 (d_20) [SPILL=0x20]
[%xmm0]: [20.0-21.0), DEF(20.0, hint=R4)!, USE(21.0/1, hint=R9)!
[%xmm1]: [20.0-21.0), DEF(20.0, hint=R4)!, USE(21.0/1, hint=R9)!
: [21.0-24.0), [26.0-29.0), [31.0-33.0)
: [33.0-33.1), USE(33.1/2)
R9 (d_21) [%xmm0]: [21.0-23.1), DEF(21.0, hint=R8)!, USE(23.1/22.1)!
R9 (d_21) [%xmm1]: [21.0-23.1), DEF(21.0, hint=R8)!, USE(23.1/22.1)!
R10 (d_32) [%xmm1]: [32.0-35.0), DEF(32.0, hint=R4)!, USE(35.0/1, hint=R12)!, USE(35.0/2)
R11 (d_33) [%xmm0]: [33.0-34.0), DEF(33.0, hint=R7)!, USE(34.0/1, hint=R5)!
R12 (d_35) [%xmm1]: [35.0-36.0), DEF(35.0, hint=R10)!, USE(36.0/1, hint=R4)!
@ -145,28 +145,29 @@ test:
movsd %xmm1, 8(%rsp)
xorpd %xmm0, %xmm0
movsd %xmm0, 0x10(%rsp)
xorpd %xmm1, %xmm1
xorpd %xmm0, %xmm0
movsd %xmm0, 0x18(%rsp)
xorl %eax, %eax
.L1:
leal 1(%rax), %eax
movsd 0x10(%rsp), %xmm0
movsd 0x18(%rsp), %xmm0
mulsd %xmm0, %xmm0
movsd %xmm0, 0x18(%rsp)
movapd %xmm1, %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, 0x20(%rsp)
addsd 0x18(%rsp), %xmm0
ucomisd .L5(%rip), %xmm0
movsd 0x10(%rsp), %xmm1
mulsd %xmm1, %xmm1
movsd %xmm1, 0x20(%rsp)
addsd %xmm0, %xmm1
ucomisd .L5(%rip), %xmm1
ja .L2
cmpl $0x3e8, %eax
jg .L3
mulsd 0x10(%rsp), %xmm1
movsd 0x18(%rsp), %xmm0
movsd 0x10(%rsp), %xmm1
mulsd 0x18(%rsp), %xmm1
subsd 0x20(%rsp), %xmm0
addsd 8(%rsp), %xmm0
movsd %xmm0, 0x10(%rsp)
movsd %xmm0, 0x18(%rsp)
addsd %xmm1, %xmm1
addsd (%rsp), %xmm1
movsd %xmm1, 0x10(%rsp)
jmp .L1
.L2:
addq $0x28, %rsp
@ -176,7 +177,7 @@ test:
addq $0x28, %rsp
retq
.rodata
.db 0x90, 0x90, 0x90
.db 0x90, 0x90, 0x90, 0x90, 0x90
.L4:
.db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x3f
.L5:

View File

@ -66,54 +66,51 @@ x86
}
--EXPECT--
test:
subl $0x18, %esp
movl %ebx, 0x14(%esp)
movl %ebp, 0x10(%esp)
movl %esi, 0xc(%esp)
movl %edi, 8(%esp)
movl 0x1c(%esp), %eax
movl 0x20(%esp), %ecx
movl 0x24(%esp), %edx
movl 0x28(%esp), %ebx
movl %edx, %ebp
imull %ecx, %ebp
movl %ebp, (%esp)
leal 4(%ebp), %ebp
movl %ebp, 4(%esp)
subl $0x14, %esp
movl %ebx, 0x10(%esp)
movl %ebp, 0xc(%esp)
movl %esi, 8(%esp)
movl %edi, 4(%esp)
movl 0x18(%esp), %eax
movl 0x1c(%esp), %ecx
movl 0x24(%esp), %ebx
movl 0x2c(%esp), %ebp
imull %ecx, %edx
movl %edx, (%esp)
leal 4(%edx), %edx
.L1:
cmpl $0, 0x3c(%esp)
cmpl $0, 0x38(%esp)
je .L3
movl 4(%esp), %eax
movl %eax, 0x30(%esp)
movl %edx, %eax
movl %edx, %ebp
movl 0x20(%esp), %eax
.L2:
cmpl $0, 0x40(%esp)
cmpl $0, 0x3c(%esp)
jne .L1
movl %eax, %esi
imull %ecx, %esi
addl %ecx, %eax
addl %edx, %eax
addl %ebx, %eax
movl (%esp), %edi
movl 0x20(%esp), %edi
addl %edi, %eax
movl 0x30(%esp), %ebp
addl %ebx, %eax
movl (%esp), %edx
addl %edx, %eax
addl %ebp, %eax
movl 0x34(%esp), %ecx
movl 0x30(%esp), %ecx
addl %ecx, %eax
movl 0x38(%esp), %edi
movl 0x34(%esp), %edi
addl %edi, %eax
leal 1(%eax, %esi), %eax
movl 0x14(%esp), %ebx
movl 0x10(%esp), %ebp
movl 0xc(%esp), %esi
movl 8(%esp), %edi
addl $0x18, %esp
movl 0x10(%esp), %ebx
movl 0xc(%esp), %ebp
movl 8(%esp), %esi
movl 4(%esp), %edi
addl $0x14, %esp
retl
.L3:
movl %eax, %esi
imull %ecx, %esi
movl %esi, 0x34(%esp)
movl %esi, 0x30(%esp)
leal 1(%esi), %edi
movl %edi, 0x38(%esp)
movl %edx, %ebx
movl %edi, 0x34(%esp)
movl 0x20(%esp), %ebx
jmp .L2

View File

@ -115,22 +115,22 @@ R3 (d_5) [SPILL=0x0]
[%xmm1]: [5.0-10.2), DEF(5.0, hint=R2)!
: [10.2-24.0), [26.0-29.0), [31.0-34.0)
: [34.0-38.0), USE(34.1/2)
R4 (d_12, d_36) [%xmm1]: [11.0-24.0), [26.0-29.0), [31.0-32.0), [36.0-38.0), DEF(12.2), USE(20.0/1, hint=R8)!, USE(20.0/2), USE(32.0/1)!, DEF(36.0, hint=R12)!, PHI_USE(37.2, phi=d_12/3)
R5 (d_13, d_34) [SPILL=0x8]
R4 (d_12, d_36) [SPILL=0x8]
[%xmm1]: [11.0-20.0), DEF(12.2), USE(20.0/1, hint=R8)!, USE(20.0/2)
: [20.0-24.0), [26.0-29.0), [31.0-31.3)
[%xmm1]: [31.3-32.0), [36.0-38.0), USE(32.0/1)!, DEF(36.0, hint=R12)!, PHI_USE(37.2, phi=d_12/3)
R5 (d_13, d_34) [SPILL=0x10]
[%xmm0]: [11.0-18.0), DEF(13.2), USE(18.0/1, hint=R7)!, USE(18.0/2)
: [18.0-24.0), [26.0-29.0), [31.0-32.0)
[%xmm0]: [32.0-32.1), [34.0-38.0), USE(32.1/2, hint=R10), DEF(34.0, hint=R11)!, PHI_USE(37.2, phi=d_13/3)
: [32.0-32.1), USE(32.1/2, hint=R10)
[%xmm0]: [34.0-38.0), DEF(34.0, hint=R11)!, PHI_USE(37.2, phi=d_13/3)
R6 (d_14, d_15) [%eax]: [11.0-15.1), [15.2-25.0), [26.0-29.0), [31.0-38.0), DEF(14.2), USE(15.1/1)!, DEF(15.2)!, USE(25.0/2, hint=%eax), USE(28.1/27.1), PHI_USE(37.2, phi=d_14/3)
R7 (d_18) [SPILL=0x10]
[%xmm0]: [18.0-20.0), DEF(18.0, hint=R5)!
: [20.0-21.0)
: [21.0-24.0), [26.0-29.0), [31.0-32.3), USE(21.1/2)
[%xmm0]: [32.3-33.0), USE(33.0/1, hint=R11)!
R7 (d_18) [%xmm0]: [18.0-24.0), [26.0-29.0), [31.0-33.0), DEF(18.0, hint=R5)!, USE(21.1/2), USE(33.0/1, hint=R11)!
R8 (d_20) [SPILL=0x18]
[%xmm0]: [20.0-21.0), DEF(20.0, hint=R4)!, USE(21.0/1, hint=R9)!
[%xmm1]: [20.0-21.0), DEF(20.0, hint=R4)!, USE(21.0/1, hint=R9)!
: [21.0-24.0), [26.0-29.0), [31.0-33.0)
: [33.0-33.1), USE(33.1/2)
R9 (d_21) [%xmm0]: [21.0-23.1), DEF(21.0, hint=R8)!, USE(23.1/22.1)!
R9 (d_21) [%xmm1]: [21.0-23.1), DEF(21.0, hint=R8)!, USE(23.1/22.1)!
R10 (d_32) [%xmm1]: [32.0-35.0), DEF(32.0, hint=R4)!, USE(35.0/1, hint=R12)!, USE(35.0/2)
R11 (d_33) [%xmm0]: [33.0-34.0), DEF(33.0, hint=R7)!, USE(34.0/1, hint=R5)!
R12 (d_35) [%xmm1]: [35.0-36.0), DEF(35.0, hint=R10)!, USE(36.0/1, hint=R4)!
@ -143,28 +143,29 @@ test:
movsd %xmm1, (%esp)
xorpd %xmm0, %xmm0
movsd %xmm0, 8(%esp)
xorpd %xmm1, %xmm1
xorpd %xmm0, %xmm0
movsd %xmm0, 0x10(%esp)
xorl %eax, %eax
.L1:
leal 1(%eax), %eax
movsd 8(%esp), %xmm0
movsd 0x10(%esp), %xmm0
mulsd %xmm0, %xmm0
movsd %xmm0, 0x10(%esp)
movapd %xmm1, %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, 0x18(%esp)
addsd 0x10(%esp), %xmm0
ucomisd .L5, %xmm0
movsd 8(%esp), %xmm1
mulsd %xmm1, %xmm1
movsd %xmm1, 0x18(%esp)
addsd %xmm0, %xmm1
ucomisd .L5, %xmm1
ja .L2
cmpl $0x3e8, %eax
jg .L3
mulsd 8(%esp), %xmm1
movsd 0x10(%esp), %xmm0
movsd 8(%esp), %xmm1
mulsd 0x10(%esp), %xmm1
subsd 0x18(%esp), %xmm0
addsd (%esp), %xmm0
movsd %xmm0, 8(%esp)
movsd %xmm0, 0x10(%esp)
addsd %xmm1, %xmm1
addsd 0x24(%esp), %xmm1
movsd %xmm1, 8(%esp)
jmp .L1
.L2:
addl $0x20, %esp
@ -174,7 +175,6 @@ test:
addl $0x20, %esp
retl
.rodata
.db 0x90, 0x90, 0x90, 0x90, 0x90, 0x90
.L4:
.db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x3f
.L5:

View File

@ -115,22 +115,22 @@ R3 (d_5) [SPILL=0x8]
[%xmm1]: [5.0-10.2), DEF(5.0, hint=R2)!
: [10.2-24.0), [26.0-29.0), [31.0-34.0)
: [34.0-38.0), USE(34.1/2)
R4 (d_12, d_36) [%xmm1]: [11.0-24.0), [26.0-29.0), [31.0-32.0), [36.0-38.0), DEF(12.2), USE(20.0/1, hint=R8)!, USE(20.0/2), USE(32.0/1)!, DEF(36.0, hint=R12)!, PHI_USE(37.2, phi=d_12/3)
R5 (d_13, d_34) [SPILL=0x10]
R4 (d_12, d_36) [SPILL=0x10]
[%xmm1]: [11.0-20.0), DEF(12.2), USE(20.0/1, hint=R8)!, USE(20.0/2)
: [20.0-24.0), [26.0-29.0), [31.0-31.3)
[%xmm1]: [31.3-32.0), [36.0-38.0), USE(32.0/1)!, DEF(36.0, hint=R12)!, PHI_USE(37.2, phi=d_12/3)
R5 (d_13, d_34) [SPILL=0x18]
[%xmm0]: [11.0-18.0), DEF(13.2), USE(18.0/1, hint=R7)!, USE(18.0/2)
: [18.0-24.0), [26.0-29.0), [31.0-32.0)
[%xmm0]: [32.0-32.1), [34.0-38.0), USE(32.1/2, hint=R10), DEF(34.0, hint=R11)!, PHI_USE(37.2, phi=d_13/3)
: [32.0-32.1), USE(32.1/2, hint=R10)
[%xmm0]: [34.0-38.0), DEF(34.0, hint=R11)!, PHI_USE(37.2, phi=d_13/3)
R6 (d_14, d_15) [%eax]: [11.0-15.1), [15.2-25.0), [26.0-29.0), [31.0-38.0), DEF(14.2), USE(15.1/1)!, DEF(15.2)!, USE(25.0/2, hint=%eax), USE(28.1/27.1), PHI_USE(37.2, phi=d_14/3)
R7 (d_18) [SPILL=0x18]
[%xmm0]: [18.0-20.0), DEF(18.0, hint=R5)!
: [20.0-21.0)
: [21.0-24.0), [26.0-29.0), [31.0-32.3), USE(21.1/2)
[%xmm0]: [32.3-33.0), USE(33.0/1, hint=R11)!
R7 (d_18) [%xmm0]: [18.0-24.0), [26.0-29.0), [31.0-33.0), DEF(18.0, hint=R5)!, USE(21.1/2), USE(33.0/1, hint=R11)!
R8 (d_20) [SPILL=0x20]
[%xmm0]: [20.0-21.0), DEF(20.0, hint=R4)!, USE(21.0/1, hint=R9)!
[%xmm1]: [20.0-21.0), DEF(20.0, hint=R4)!, USE(21.0/1, hint=R9)!
: [21.0-24.0), [26.0-29.0), [31.0-33.0)
: [33.0-33.1), USE(33.1/2)
R9 (d_21) [%xmm0]: [21.0-23.1), DEF(21.0, hint=R8)!, USE(23.1/22.1)!
R9 (d_21) [%xmm1]: [21.0-23.1), DEF(21.0, hint=R8)!, USE(23.1/22.1)!
R10 (d_32) [%xmm1]: [32.0-35.0), DEF(32.0, hint=R4)!, USE(35.0/1, hint=R12)!, USE(35.0/2)
R11 (d_33) [%xmm0]: [33.0-34.0), DEF(33.0, hint=R7)!, USE(34.0/1, hint=R5)!
R12 (d_35) [%xmm1]: [35.0-36.0), DEF(35.0, hint=R10)!, USE(36.0/1, hint=R4)!
@ -145,28 +145,29 @@ test:
movsd %xmm1, 8(%rsp)
xorpd %xmm0, %xmm0
movsd %xmm0, 0x10(%rsp)
xorpd %xmm1, %xmm1
xorpd %xmm0, %xmm0
movsd %xmm0, 0x18(%rsp)
xorl %eax, %eax
.L1:
leal 1(%rax), %eax
movsd 0x10(%rsp), %xmm0
movsd 0x18(%rsp), %xmm0
mulsd %xmm0, %xmm0
movsd %xmm0, 0x18(%rsp)
movapd %xmm1, %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, 0x20(%rsp)
addsd 0x18(%rsp), %xmm0
ucomisd .L5(%rip), %xmm0
movsd 0x10(%rsp), %xmm1
mulsd %xmm1, %xmm1
movsd %xmm1, 0x20(%rsp)
addsd %xmm0, %xmm1
ucomisd .L5(%rip), %xmm1
ja .L2
cmpl $0x3e8, %eax
jg .L3
mulsd 0x10(%rsp), %xmm1
movsd 0x18(%rsp), %xmm0
movsd 0x10(%rsp), %xmm1
mulsd 0x18(%rsp), %xmm1
subsd 0x20(%rsp), %xmm0
addsd 8(%rsp), %xmm0
movsd %xmm0, 0x10(%rsp)
movsd %xmm0, 0x18(%rsp)
addsd %xmm1, %xmm1
addsd (%rsp), %xmm1
movsd %xmm1, 0x10(%rsp)
jmp .L1
.L2:
addq $0x28, %rsp
@ -176,7 +177,7 @@ test:
addq $0x28, %rsp
retq
.rodata
.db 0x90, 0x90, 0x90
.db 0x90, 0x90, 0x90, 0x90, 0x90
.L4:
.db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x3f
.L5: