-
Notifications
You must be signed in to change notification settings - Fork 102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
optimize HandleMathClamp #1160
optimize HandleMathClamp #1160
Conversation
OpCode.THROW also exists in many other files, mainly for checking value overflows. |
you can disable the gasassert for this pr |
methodConvert.AddInstruction(OpCode.DROP); | ||
methodConvert.Jump(OpCode.JMP, endTarget); | ||
endTarget.Instruction = methodConvert.AddInstruction(OpCode.NOP); | ||
methodConvert.AddInstruction(OpCode.REVERSE3); // 10 0 5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
//We may not use MAX and MIN after REVERSE3 because it's more expensive. MAX&MIN costs 1<<3 each. See the commented codes for a cheaper but larger solution.
…to optimize-clamp # Conflicts: # tests/Neo.Compiler.CSharp.UnitTests/TestingArtifacts/Contract_Integer.cs # tests/Neo.Compiler.CSharp.UnitTests/TestingArtifacts/Contract_Math.cs
It's not only a performance optimization. max == min should be allowed. This is the same as the behavior of C# https://github.com/dotnet/runtime/blob/5535e31a712343a63f5d7d796cd874e563e5ac14/src/libraries/System.Private.CoreLib/src/System/Math.cs#L636C13-L650C26