[MLton-devel] Extra instruction in (n div 2)
Matthew Fluet
MLton@mlton.org
Wed, 12 Feb 2003 13:02:26 -0500 (EST)
Thanks Tom! Especially for taking the time to track down where the
optimization was being missed. I've checked in the change.
-Matthew
On Wed, 12 Feb 2003, Tom Murphy wrote:
>
> 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
>
-------------------------------------------------------
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