[PATCH v1] x86-64: Replace `%ah` write with `%eax` read

Noah Goldstein goldstein.w.n@gmail.com
Fri Mar 10 02:44:20 GMT 2023


High8 partial registers can incur a stall when being modified (if not
renamed seperately), or at the very least incur extra backend uops (if
renamed seperately). Either way `testl $0x0400, %eax` is preferable to
`andb $0x04, %ah`.

Function size is unchanged when accounting for 16-byte padding.
---
 sysdeps/x86_64/fpu/e_fmodl.S | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sysdeps/x86_64/fpu/e_fmodl.S b/sysdeps/x86_64/fpu/e_fmodl.S
index d754668bce..d45f984e1a 100644
--- a/sysdeps/x86_64/fpu/e_fmodl.S
+++ b/sysdeps/x86_64/fpu/e_fmodl.S
@@ -13,7 +13,7 @@ ENTRY(__ieee754_fmodl)
 	fldt	8(%rsp)
 1:	fprem
 	fstsw	%ax
-	and	$04,%ah
+	testl	$0x400,%eax
 	jnz	1b
 	fstp	%st(1)
 	ret
-- 
2.34.1



More information about the Libc-alpha mailing list