-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
reduce op count for isinteger, add tests #14569
Conversation
No, this is great. I'd love to audit all of the simple numeric functions in base and make sure that they generate sane code and see if each one can be made any more efficient. |
4f6052b
to
e6ee3f8
Compare
e6ee3f8
to
b48aa3b
Compare
There probably won't be any real performance benefit until we enable new LLVM, as that should hopefully inline the |
This seems to have 12-13% performance improvement with LLVM 3.7 =) |
It would be great if we could begin to add benchmarks for this stuff. cc @jrevels |
I wonder if benchmarking is really the best way to test for this kind of thing. Maybe checking for specific LLVM assembly? Of course, that doesn't address regressions in LLVM codegen, so maybe both. |
LGTM, I like the test additions. |
reduce op count for isinteger, add tests
@jrevels I guess the benchmark label was added for the idea of measuring the llvm (i.e. by LOC/instructions?) |
My guess is that @jakebolewski added it because he thought we should perform actual timing measurements, so I added benchmarks that check various scalar predicates. Adding tests that check the LLVM bitcode might be useful, but I'm not sure I'm knowledgable enough to write such a test effectively, and it's not currently something that gets covered by BaseBenchmarks.jl. |
This is a very slight tweak to the implementation of `isinteger(::AbstractFloat)` to use `iszero` rather than `== 0`. It shouldn't make any difference with any of the built-in floating-point types, but `iszero` might conceivably be faster for some user-defined types. I also added a comment to indicate why it's using `iszero(x - trunc(x))` rather than `x == trunc(x)` (due to non-finite values); this code dates back to #14569 in Julia 0.5. --------- Co-authored-by: Sukera <[email protected]>
This is a very slight tweak to the implementation of `isinteger(::AbstractFloat)` to use `iszero` rather than `== 0`. It shouldn't make any difference with any of the built-in floating-point types, but `iszero` might conceivably be faster for some user-defined types. I also added a comment to indicate why it's using `iszero(x - trunc(x))` rather than `x == trunc(x)` (due to non-finite values); this code dates back to JuliaLang#14569 in Julia 0.5. --------- Co-authored-by: Sukera <[email protected]>
Okay, not the biggest optimisation in the world, but we reduce
to