From f38e968abafde345fa470cb14d55b6f092af569f Mon Sep 17 00:00:00 2001 From: Cherry Mui Date: Mon, 8 Dec 2025 12:14:24 -0500 Subject: [dev.simd] cmd/compile: zero only low 128-bit of X15 Zeroing the upper part of X15 may make the CPU think it is "dirty" and slow down SSE operations. For now, just not zeroing the upper part, and construct a zero value on the fly if we need a 256- or 512-bit zero value. Maybe VZEROUPPER works better than explicitly zeroing X15, but we need to evaluate. Long term, we probably want to move more things from SSE to AVX. This essentially undoes CL 698237 and CL 698238, except keeping using X15 for 128-bit zeroing for SIMD. Change-Id: I1564e6332c4c57f9721397c92c7c734c5497534c Reviewed-on: https://go-review.googlesource.com/c/go/+/728240 LUCI-TryBot-Result: Go LUCI Reviewed-by: David Chase --- src/runtime/asm_amd64.s | 10 ---------- src/runtime/race_amd64.s | 5 ----- src/runtime/sys_darwin_amd64.s | 5 ----- src/runtime/sys_dragonfly_amd64.s | 5 ----- src/runtime/sys_freebsd_amd64.s | 10 ---------- src/runtime/sys_linux_amd64.s | 10 ---------- src/runtime/sys_netbsd_amd64.s | 5 ----- src/runtime/sys_openbsd_amd64.s | 5 ----- src/runtime/sys_windows_amd64.s | 5 ----- 9 files changed, 60 deletions(-) (limited to 'src/runtime') diff --git a/src/runtime/asm_amd64.s b/src/runtime/asm_amd64.s index bf208a4d29..391d9bcd22 100644 --- a/src/runtime/asm_amd64.s +++ b/src/runtime/asm_amd64.s @@ -1093,11 +1093,6 @@ needm: // there's no need to handle that. Clear R14 so that there's // a bad value in there, in case needm tries to use it. XORPS X15, X15 -#ifdef GOEXPERIMENT_simd - CMPB internal∕cpu·X86+const_offsetX86HasAVX(SB), $1 - JNE 2(PC) - VXORPS X15, X15, X15 -#endif XORQ R14, R14 MOVQ $runtime·needAndBindM(SB), AX CALL AX @@ -1795,11 +1790,6 @@ TEXT ·sigpanic0(SB),NOSPLIT,$0-0 get_tls(R14) MOVQ g(R14), R14 XORPS X15, X15 -#ifdef GOEXPERIMENT_simd - CMPB internal∕cpu·X86+const_offsetX86HasAVX(SB), $1 - JNE 2(PC) - VXORPS X15, X15, X15 -#endif JMP ·sigpanic(SB) // gcWriteBarrier informs the GC about heap pointer writes. diff --git a/src/runtime/race_amd64.s b/src/runtime/race_amd64.s index ade29bc5f1..e19118bd54 100644 --- a/src/runtime/race_amd64.s +++ b/src/runtime/race_amd64.s @@ -456,11 +456,6 @@ call: // Back to Go world, set special registers. // The g register (R14) is preserved in C. XORPS X15, X15 -#ifdef GOEXPERIMENT_simd - CMPB internal∕cpu·X86+const_offsetX86HasAVX(SB), $1 - JNE 2(PC) - VXORPS X15, X15, X15 -#endif RET // C->Go callback thunk that allows to call runtime·racesymbolize from C code. diff --git a/src/runtime/sys_darwin_amd64.s b/src/runtime/sys_darwin_amd64.s index e033e8b702..99d67a9cfd 100644 --- a/src/runtime/sys_darwin_amd64.s +++ b/src/runtime/sys_darwin_amd64.s @@ -177,11 +177,6 @@ TEXT runtime·sigtramp(SB),NOSPLIT|TOPFRAME|NOFRAME,$0 get_tls(R12) MOVQ g(R12), R14 PXOR X15, X15 -#ifdef GOEXPERIMENT_simd - CMPB internal∕cpu·X86+const_offsetX86HasAVX(SB), $1 - JNE 2(PC) - VXORPS X15, X15, X15 -#endif // Reserve space for spill slots. NOP SP // disable vet stack checking diff --git a/src/runtime/sys_dragonfly_amd64.s b/src/runtime/sys_dragonfly_amd64.s index e417d4b8a8..a223c2cf76 100644 --- a/src/runtime/sys_dragonfly_amd64.s +++ b/src/runtime/sys_dragonfly_amd64.s @@ -228,11 +228,6 @@ TEXT runtime·sigtramp(SB),NOSPLIT|TOPFRAME|NOFRAME,$0 get_tls(R12) MOVQ g(R12), R14 PXOR X15, X15 -#ifdef GOEXPERIMENT_simd - CMPB internal∕cpu·X86+const_offsetX86HasAVX(SB), $1 - JNE 2(PC) - VXORPS X15, X15, X15 -#endif // Reserve space for spill slots. NOP SP // disable vet stack checking diff --git a/src/runtime/sys_freebsd_amd64.s b/src/runtime/sys_freebsd_amd64.s index bab275cc72..977ea093d2 100644 --- a/src/runtime/sys_freebsd_amd64.s +++ b/src/runtime/sys_freebsd_amd64.s @@ -265,11 +265,6 @@ TEXT runtime·sigtramp(SB),NOSPLIT|TOPFRAME|NOFRAME,$0 get_tls(R12) MOVQ g(R12), R14 PXOR X15, X15 -#ifdef GOEXPERIMENT_simd - CMPB internal∕cpu·X86+const_offsetX86HasAVX(SB), $1 - JNE 2(PC) - VXORPS X15, X15, X15 -#endif // Reserve space for spill slots. NOP SP // disable vet stack checking @@ -295,11 +290,6 @@ TEXT runtime·sigprofNonGoWrapper<>(SB),NOSPLIT|NOFRAME,$0 get_tls(R12) MOVQ g(R12), R14 PXOR X15, X15 -#ifdef GOEXPERIMENT_simd - CMPB internal∕cpu·X86+const_offsetX86HasAVX(SB), $1 - JNE 2(PC) - VXORPS X15, X15, X15 -#endif // Reserve space for spill slots. NOP SP // disable vet stack checking diff --git a/src/runtime/sys_linux_amd64.s b/src/runtime/sys_linux_amd64.s index 618553b196..878f834748 100644 --- a/src/runtime/sys_linux_amd64.s +++ b/src/runtime/sys_linux_amd64.s @@ -352,11 +352,6 @@ TEXT runtime·sigtramp(SB),NOSPLIT|TOPFRAME|NOFRAME,$0 get_tls(R12) MOVQ g(R12), R14 PXOR X15, X15 -#ifdef GOEXPERIMENT_simd - CMPB internal∕cpu·X86+const_offsetX86HasAVX(SB), $1 - JNE 2(PC) - VXORPS X15, X15, X15 -#endif // Reserve space for spill slots. NOP SP // disable vet stack checking @@ -382,11 +377,6 @@ TEXT runtime·sigprofNonGoWrapper<>(SB),NOSPLIT|NOFRAME,$0 get_tls(R12) MOVQ g(R12), R14 PXOR X15, X15 -#ifdef GOEXPERIMENT_simd - CMPB internal∕cpu·X86+const_offsetX86HasAVX(SB), $1 - JNE 2(PC) - VXORPS X15, X15, X15 -#endif // Reserve space for spill slots. NOP SP // disable vet stack checking diff --git a/src/runtime/sys_netbsd_amd64.s b/src/runtime/sys_netbsd_amd64.s index 946b1fbe22..2f1ddcdc89 100644 --- a/src/runtime/sys_netbsd_amd64.s +++ b/src/runtime/sys_netbsd_amd64.s @@ -310,11 +310,6 @@ TEXT runtime·sigtramp(SB),NOSPLIT|TOPFRAME|NOFRAME,$0 get_tls(R12) MOVQ g(R12), R14 PXOR X15, X15 -#ifdef GOEXPERIMENT_simd - CMPB internal∕cpu·X86+const_offsetX86HasAVX(SB), $1 - JNE 2(PC) - VXORPS X15, X15, X15 -#endif // Reserve space for spill slots. NOP SP // disable vet stack checking diff --git a/src/runtime/sys_openbsd_amd64.s b/src/runtime/sys_openbsd_amd64.s index 7766fa5194..ff0bc2416a 100644 --- a/src/runtime/sys_openbsd_amd64.s +++ b/src/runtime/sys_openbsd_amd64.s @@ -64,11 +64,6 @@ TEXT runtime·sigtramp(SB),NOSPLIT|TOPFRAME|NOFRAME,$0 get_tls(R12) MOVQ g(R12), R14 PXOR X15, X15 -#ifdef GOEXPERIMENT_simd - CMPB internal∕cpu·X86+const_offsetX86HasAVX(SB), $1 - JNE 2(PC) - VXORPS X15, X15, X15 -#endif // Reserve space for spill slots. NOP SP // disable vet stack checking diff --git a/src/runtime/sys_windows_amd64.s b/src/runtime/sys_windows_amd64.s index 52a21ba89b..e438599910 100644 --- a/src/runtime/sys_windows_amd64.s +++ b/src/runtime/sys_windows_amd64.s @@ -32,11 +32,6 @@ TEXT sigtramp<>(SB),NOSPLIT,$0-0 // R14 is cleared in case there's a non-zero value in there // if called from a non-go thread. XORPS X15, X15 -#ifdef GOEXPERIMENT_simd - CMPB internal∕cpu·X86+const_offsetX86HasAVX(SB), $1 - JNE 2(PC) - VXORPS X15, X15, X15 -#endif XORQ R14, R14 get_tls(AX) -- cgit v1.3