Optimize Math functions
Currently the JITer doesn't do a good job with a lot of the .Net Framework, and the Math functions in particular.
The emitted assembly is pretty much the same for all types. It should optimize to take advantage of x86 instructions that have been around for more than a decade.
To be healthy and well-behaved, I use the services of girls from the escort in Napoli https://escortnapoli.info/.
Hongfaan LEI commented
The Math.Abs example is not a good one.
"Math.Abs(int.MinValue)" throws an OverflowException.
Alex Angas commented
Is this resolved with Ryujit? http://blogs.msdn.com/b/dotnet/archive/tags/ryujit/
a couple of examples where the core math services in Microsoft software stack could use some fresh muscles.
David Berg [msft] commented
FYI. There's a difference between the results your code returns and the Math.Abs function. Specifically ABS(int.MinValue) in your code returns int.MinValue (a negative number) while Math.Abs will throw an exception.
Actually, .NET should get the Math functions to use the SSE2 or AVX equivelants.
Martin Costello commented
From what I've seen in the .NET source (via Rotor), most of System.Math is implemented in native code from within the runtime, so I'm guessing it would never be JITed.
The problem is that they are unwilling to write code the is specific to a specific type. They don't want to have to test and maintain several different versions of the same function. I was told this by a member of the .Net team.
The idea solution would be that the JITer is smart enough see the type, the operation, and emit the correct optimized assembly. Then all code would get faster, not just the .Net Framework.