[MLton-devel] Extra instruction in (n div 2)
Tom Murphy
MLton@mlton.org
Wed, 12 Feb 2003 12:23:47 -0500 (EST)
The code "n div 2" is compiled to this:
movl %edx,%ecx
sarl $0,%ecx
shrl $31,%ecx
addl %ecx,%edx
sarl $1,%edx
The second instruction is a no-op -- a shift by zero doesn't even affect
the flags.
This can be fixed by changing
mlton/codegen/x86-codegen/x86-simplify.fun:1599 from:
=> if i > 0
(* then emit sar instruction with count i - 1 *)
to
=> if i > 1
- Tom
[ NEW! : http://tom7.org/ ]
[ OLD! : http://fonts.tom7.com/ ]
-------------------------------------------------------
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
http://www.vasoftware.com
_______________________________________________
MLton-devel mailing list
MLton-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mlton-devel