Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cranelift(x64): Make xmm{8..15} registers non-preferred #7089

Merged
merged 1 commit into from
Sep 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 14 additions & 11 deletions cranelift/codegen/src/isa/x64/abi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1243,7 +1243,8 @@ fn create_reg_env_systemv(enable_pinned_reg: bool) -> MachineEnv {
preg(regs::r10()),
preg(regs::r11()),
],
// Preferred XMMs: all of them.
// Preferred XMMs: the first 8, which can have smaller encodings
// with AVX instructions.
vec![
preg(regs::xmm0()),
preg(regs::xmm1()),
Expand All @@ -1253,14 +1254,6 @@ fn create_reg_env_systemv(enable_pinned_reg: bool) -> MachineEnv {
preg(regs::xmm5()),
preg(regs::xmm6()),
preg(regs::xmm7()),
preg(regs::xmm8()),
preg(regs::xmm9()),
preg(regs::xmm10()),
preg(regs::xmm11()),
preg(regs::xmm12()),
preg(regs::xmm13()),
preg(regs::xmm14()),
preg(regs::xmm15()),
],
// The Vector Regclass is unused
vec![],
Expand All @@ -1273,8 +1266,18 @@ fn create_reg_env_systemv(enable_pinned_reg: bool) -> MachineEnv {
preg(regs::r13()),
preg(regs::r14()),
],
// Non-preferred XMMs: none.
vec![],
// Non-preferred XMMs: the last 8 registers, which can have larger
// encodings with AVX instructions.
vec![
preg(regs::xmm8()),
preg(regs::xmm9()),
preg(regs::xmm10()),
preg(regs::xmm11()),
preg(regs::xmm12()),
preg(regs::xmm13()),
preg(regs::xmm14()),
preg(regs::xmm15()),
],
// The Vector Regclass is unused
vec![],
],
Expand Down
24 changes: 12 additions & 12 deletions cranelift/filetests/filetests/isa/x64/call-conv.clif
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,8 @@ block0(
; movq %rax, %rdi
; movq 16(%rbp), %r10
; movq 24(%rbp), %r11
; movss 32(%rbp), %xmm9
; movsd 40(%rbp), %xmm8
; movss 32(%rbp), %xmm11
; movsd 40(%rbp), %xmm13
; subq %rsp, $144, %rsp
; virtual_sp_offset_adjust 144
; movq %r8, 32(%rsp)
Expand All @@ -218,8 +218,8 @@ block0(
; movsd %xmm7, 104(%rsp)
; movq %r10, 112(%rsp)
; movl %r11d, 120(%rsp)
; movss %xmm9, 128(%rsp)
; movsd %xmm8, 136(%rsp)
; movss %xmm11, 128(%rsp)
; movsd %xmm13, 136(%rsp)
; movq %rdi, %r9
; movq %rcx, %r8
; movq %rsi, %rcx
Expand All @@ -242,8 +242,8 @@ block0(
; movq %rax, %rdi
; movq 0x10(%rbp), %r10
; movq 0x18(%rbp), %r11
; movss 0x20(%rbp), %xmm9
; movsd 0x28(%rbp), %xmm8
; movss 0x20(%rbp), %xmm11
; movsd 0x28(%rbp), %xmm13
; subq $0x90, %rsp
; movq %r8, 0x20(%rsp)
; movq %r9, 0x28(%rsp)
Expand All @@ -257,8 +257,8 @@ block0(
; movsd %xmm7, 0x68(%rsp)
; movq %r10, 0x70(%rsp)
; movl %r11d, 0x78(%rsp)
; movss %xmm9, 0x80(%rsp)
; movsd %xmm8, 0x88(%rsp)
; movss %xmm11, 0x80(%rsp)
; movsd %xmm13, 0x88(%rsp)
; movq %rdi, %r9
; movq %rcx, %r8
; movq %rsi, %rcx
Expand Down Expand Up @@ -330,7 +330,7 @@ block0(v0: i32, v1: f32, v2: i64, v3: f64, v4: i32, v5: i32, v6: i32, v7: f32, v
; block0:
; movq %rsi, %r9
; movq %rdi, %rsi
; movdqa %xmm1, %xmm12
; movdqa %xmm1, %xmm6
; movdqa %xmm0, %xmm1
; subq %rsp, $96, %rsp
; virtual_sp_offset_adjust 96
Expand All @@ -343,7 +343,7 @@ block0(v0: i32, v1: f32, v2: i64, v3: f64, v4: i32, v5: i32, v6: i32, v7: f32, v
; movsd %xmm5, 80(%rsp)
; movq %rsi, %rcx
; movq %r9, %r8
; movdqa %xmm12, %xmm3
; movdqa %xmm6, %xmm3
; call *%rcx
; addq %rsp, $96, %rsp
; virtual_sp_offset_adjust -96
Expand All @@ -358,7 +358,7 @@ block0(v0: i32, v1: f32, v2: i64, v3: f64, v4: i32, v5: i32, v6: i32, v7: f32, v
; block1: ; offset 0x4
; movq %rsi, %r9
; movq %rdi, %rsi
; movdqa %xmm1, %xmm12
; movdqa %xmm1, %xmm6
; movdqa %xmm0, %xmm1
; subq $0x60, %rsp
; movl %edx, 0x20(%rsp)
Expand All @@ -370,7 +370,7 @@ block0(v0: i32, v1: f32, v2: i64, v3: f64, v4: i32, v5: i32, v6: i32, v7: f32, v
; movsd %xmm5, 0x50(%rsp)
; movq %rsi, %rcx
; movq %r9, %r8
; movdqa %xmm12, %xmm3
; movdqa %xmm6, %xmm3
; callq *%rcx
; addq $0x60, %rsp
; movq %rbp, %rsp
Expand Down
16 changes: 8 additions & 8 deletions cranelift/filetests/filetests/isa/x64/cmp-mem-bug.clif
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ block0(v0: f64, v1: i64):
; pushq %rbp
; movq %rsp, %rbp
; block0:
; movsd 0(%rdi), %xmm9
; ucomisd %xmm9, %xmm0
; movsd 0(%rdi), %xmm1
; ucomisd %xmm1, %xmm0
; setnp %dil
; setz %al
; andl %edi, %eax, %edi
; movzbq %dil, %rax
; ucomisd %xmm9, %xmm0
; ucomisd %xmm1, %xmm0
; movdqa %xmm0, %xmm2
; movsd %xmm0, %xmm0; jnp $next; movsd %xmm2, %xmm0; $next:
; movsd %xmm0, %xmm0; jz $next; movsd %xmm2, %xmm0; $next:
Expand All @@ -73,17 +73,17 @@ block0(v0: f64, v1: i64):
; pushq %rbp
; movq %rsp, %rbp
; block1: ; offset 0x4
; movsd (%rdi), %xmm9 ; trap: heap_oob
; ucomisd %xmm9, %xmm0
; movsd (%rdi), %xmm1 ; trap: heap_oob
; ucomisd %xmm1, %xmm0
; setnp %dil
; sete %al
; andl %eax, %edi
; movzbq %dil, %rax
; ucomisd %xmm9, %xmm0
; ucomisd %xmm1, %xmm0
; movdqa %xmm0, %xmm2
; jnp 0x2f
; jnp 0x2c
; movsd %xmm2, %xmm0
; je 0x39
; je 0x36
; movsd %xmm2, %xmm0
; movq %rbp, %rsp
; popq %rbp
Expand Down
168 changes: 86 additions & 82 deletions cranelift/filetests/filetests/isa/x64/fastcall.clif
Original file line number Diff line number Diff line change
Expand Up @@ -356,51 +356,53 @@ block0(v0: i64):
; unwind SaveReg { clobber_offset: 144, reg: p15f }
; block0:
; movsd 0(%rcx), %xmm0
; movsd 8(%rcx), %xmm10
; movdqu %xmm10, rsp(48 + virtual offset)
; movsd 16(%rcx), %xmm5
; movsd 24(%rcx), %xmm14
; movdqu %xmm14, rsp(32 + virtual offset)
; movsd 32(%rcx), %xmm13
; movsd 40(%rcx), %xmm15
; movdqu %xmm15, rsp(16 + virtual offset)
; movsd 8(%rcx), %xmm8
; movdqu %xmm8, rsp(48 + virtual offset)
; movsd 16(%rcx), %xmm10
; movdqu %xmm10, rsp(0 + virtual offset)
; movsd 24(%rcx), %xmm9
; movdqa %xmm9, %xmm10
; movsd 32(%rcx), %xmm5
; movsd 40(%rcx), %xmm6
; movdqu %xmm6, rsp(32 + virtual offset)
; movsd 48(%rcx), %xmm7
; movsd 56(%rcx), %xmm8
; movdqu %xmm8, rsp(0 + virtual offset)
; movsd 64(%rcx), %xmm12
; movsd 72(%rcx), %xmm2
; movsd 80(%rcx), %xmm9
; movsd 88(%rcx), %xmm4
; movsd 56(%rcx), %xmm12
; movdqu %xmm12, rsp(16 + virtual offset)
; movsd 64(%rcx), %xmm4
; movsd 72(%rcx), %xmm12
; movsd 80(%rcx), %xmm1
; movsd 88(%rcx), %xmm14
; movsd 96(%rcx), %xmm3
; movsd 104(%rcx), %xmm8
; movsd 104(%rcx), %xmm15
; movsd 112(%rcx), %xmm11
; movsd 120(%rcx), %xmm10
; movsd 128(%rcx), %xmm6
; movsd 136(%rcx), %xmm14
; movsd 144(%rcx), %xmm1
; movdqu rsp(48 + virtual offset), %xmm15
; addsd %xmm0, %xmm15, %xmm0
; movdqu rsp(32 + virtual offset), %xmm15
; addsd %xmm5, %xmm15, %xmm5
; movdqu rsp(16 + virtual offset), %xmm15
; addsd %xmm13, %xmm15, %xmm13
; movdqu rsp(0 + virtual offset), %xmm15
; addsd %xmm7, %xmm15, %xmm7
; addsd %xmm12, %xmm2, %xmm12
; addsd %xmm9, %xmm4, %xmm9
; addsd %xmm3, %xmm8, %xmm3
; addsd %xmm11, %xmm10, %xmm11
; addsd %xmm6, %xmm14, %xmm6
; addsd %xmm1, 152(%rcx), %xmm1
; addsd %xmm0, %xmm5, %xmm0
; addsd %xmm13, %xmm7, %xmm13
; addsd %xmm12, %xmm9, %xmm12
; addsd %xmm3, %xmm11, %xmm3
; addsd %xmm6, %xmm1, %xmm6
; addsd %xmm0, %xmm13, %xmm0
; addsd %xmm12, %xmm3, %xmm12
; addsd %xmm0, %xmm12, %xmm0
; movsd 120(%rcx), %xmm8
; movsd 128(%rcx), %xmm2
; movsd 136(%rcx), %xmm9
; movsd 144(%rcx), %xmm13
; movdqu rsp(48 + virtual offset), %xmm6
; addsd %xmm0, %xmm6, %xmm0
; movdqa %xmm10, %xmm6
; movdqu rsp(0 + virtual offset), %xmm10
; addsd %xmm10, %xmm6, %xmm10
; movdqu rsp(32 + virtual offset), %xmm6
; addsd %xmm5, %xmm6, %xmm5
; movdqu rsp(16 + virtual offset), %xmm6
; addsd %xmm7, %xmm6, %xmm7
; addsd %xmm4, %xmm12, %xmm4
; addsd %xmm1, %xmm14, %xmm1
; addsd %xmm3, %xmm15, %xmm3
; addsd %xmm11, %xmm8, %xmm11
; addsd %xmm2, %xmm9, %xmm2
; addsd %xmm13, 152(%rcx), %xmm13
; addsd %xmm0, %xmm10, %xmm0
; addsd %xmm5, %xmm7, %xmm5
; addsd %xmm4, %xmm1, %xmm4
; addsd %xmm3, %xmm11, %xmm3
; addsd %xmm2, %xmm13, %xmm2
; addsd %xmm0, %xmm5, %xmm0
; addsd %xmm4, %xmm3, %xmm4
; addsd %xmm0, %xmm4, %xmm0
; addsd %xmm0, %xmm2, %xmm0
; movdqu 64(%rsp), %xmm6
; movdqu 80(%rsp), %xmm7
; movdqu 96(%rsp), %xmm8
Expand Down Expand Up @@ -433,51 +435,53 @@ block0(v0: i64):
; movdqu %xmm15, 0xd0(%rsp)
; block1: ; offset 0x61
; movsd (%rcx), %xmm0 ; trap: heap_oob
; movsd 8(%rcx), %xmm10 ; trap: heap_oob
; movdqu %xmm10, 0x30(%rsp)
; movsd 0x10(%rcx), %xmm5 ; trap: heap_oob
; movsd 0x18(%rcx), %xmm14 ; trap: heap_oob
; movdqu %xmm14, 0x20(%rsp)
; movsd 0x20(%rcx), %xmm13 ; trap: heap_oob
; movsd 0x28(%rcx), %xmm15 ; trap: heap_oob
; movdqu %xmm15, 0x10(%rsp)
; movsd 8(%rcx), %xmm8 ; trap: heap_oob
; movdqu %xmm8, 0x30(%rsp)
; movsd 0x10(%rcx), %xmm10 ; trap: heap_oob
; movdqu %xmm10, (%rsp)
; movsd 0x18(%rcx), %xmm9 ; trap: heap_oob
; movdqa %xmm9, %xmm10
; movsd 0x20(%rcx), %xmm5 ; trap: heap_oob
; movsd 0x28(%rcx), %xmm6 ; trap: heap_oob
; movdqu %xmm6, 0x20(%rsp)
; movsd 0x30(%rcx), %xmm7 ; trap: heap_oob
; movsd 0x38(%rcx), %xmm8 ; trap: heap_oob
; movdqu %xmm8, (%rsp)
; movsd 0x40(%rcx), %xmm12 ; trap: heap_oob
; movsd 0x48(%rcx), %xmm2 ; trap: heap_oob
; movsd 0x50(%rcx), %xmm9 ; trap: heap_oob
; movsd 0x58(%rcx), %xmm4 ; trap: heap_oob
; movsd 0x38(%rcx), %xmm12 ; trap: heap_oob
; movdqu %xmm12, 0x10(%rsp)
; movsd 0x40(%rcx), %xmm4 ; trap: heap_oob
; movsd 0x48(%rcx), %xmm12 ; trap: heap_oob
; movsd 0x50(%rcx), %xmm1 ; trap: heap_oob
; movsd 0x58(%rcx), %xmm14 ; trap: heap_oob
; movsd 0x60(%rcx), %xmm3 ; trap: heap_oob
; movsd 0x68(%rcx), %xmm8 ; trap: heap_oob
; movsd 0x68(%rcx), %xmm15 ; trap: heap_oob
; movsd 0x70(%rcx), %xmm11 ; trap: heap_oob
; movsd 0x78(%rcx), %xmm10 ; trap: heap_oob
; movsd 0x80(%rcx), %xmm6 ; trap: heap_oob
; movsd 0x88(%rcx), %xmm14 ; trap: heap_oob
; movsd 0x90(%rcx), %xmm1 ; trap: heap_oob
; movdqu 0x30(%rsp), %xmm15
; addsd %xmm15, %xmm0
; movdqu 0x20(%rsp), %xmm15
; addsd %xmm15, %xmm5
; movdqu 0x10(%rsp), %xmm15
; addsd %xmm15, %xmm13
; movdqu (%rsp), %xmm15
; addsd %xmm15, %xmm7
; addsd %xmm2, %xmm12
; addsd %xmm4, %xmm9
; addsd %xmm8, %xmm3
; addsd %xmm10, %xmm11
; addsd %xmm14, %xmm6
; addsd 0x98(%rcx), %xmm1 ; trap: heap_oob
; addsd %xmm5, %xmm0
; addsd %xmm7, %xmm13
; addsd %xmm9, %xmm12
; addsd %xmm11, %xmm3
; addsd %xmm1, %xmm6
; addsd %xmm13, %xmm0
; addsd %xmm3, %xmm12
; addsd %xmm12, %xmm0
; movsd 0x78(%rcx), %xmm8 ; trap: heap_oob
; movsd 0x80(%rcx), %xmm2 ; trap: heap_oob
; movsd 0x88(%rcx), %xmm9 ; trap: heap_oob
; movsd 0x90(%rcx), %xmm13 ; trap: heap_oob
; movdqu 0x30(%rsp), %xmm6
; addsd %xmm6, %xmm0
; movdqa %xmm10, %xmm6
; movdqu (%rsp), %xmm10
; addsd %xmm6, %xmm10
; movdqu 0x20(%rsp), %xmm6
; addsd %xmm6, %xmm5
; movdqu 0x10(%rsp), %xmm6
; addsd %xmm6, %xmm7
; addsd %xmm12, %xmm4
; addsd %xmm14, %xmm1
; addsd %xmm15, %xmm3
; addsd %xmm8, %xmm11
; addsd %xmm9, %xmm2
; addsd 0x98(%rcx), %xmm13 ; trap: heap_oob
; addsd %xmm10, %xmm0
; addsd %xmm7, %xmm5
; addsd %xmm1, %xmm4
; addsd %xmm11, %xmm3
; addsd %xmm13, %xmm2
; addsd %xmm5, %xmm0
; addsd %xmm3, %xmm4
; addsd %xmm4, %xmm0
; addsd %xmm2, %xmm0
; movdqu 0x40(%rsp), %xmm6
; movdqu 0x50(%rsp), %xmm7
; movdqu 0x60(%rsp), %xmm8
Expand Down
Loading