Skip to content
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

Cast pointer instead of value when loading array/tuple lengths? #8042

Closed
ArchRobison opened this issue Aug 18, 2014 · 2 comments
Closed

Cast pointer instead of value when loading array/tuple lengths? #8042

ArchRobison opened this issue Aug 18, 2014 · 2 comments

Comments

@ArchRobison
Copy link
Contributor

Julia currently loads array lengths by loading a pointer and casting the loaded value to an int. E.g.:

  %3 = load %jl_value_t** %2, align 8, !dbg !160, !tbaa %jtbaa_arraylen
  %4 = ptrtoint %jl_value_t* %3 to i64, !dbg !160

In somewhat similar situations, Clang casts the pointer and then does the load. There's probably no net difference for now, but I see that LLVM trunk has range metadata that can be used to indicate the ranges of integers, such as an array length, which can enable it to eliminate unnecessary checks in some cases. (I'm investigating one for a common @simd use case.) Is there any reason for the Julia instruction sequence other than it was slightly simpler to implement?

@JeffBezanson
Copy link
Sponsor Member

I think this change would be good. Casting the pointer type first makes more sense to me. If somebody gets to it before I do, I'll merge it :)

@ArchRobison
Copy link
Contributor Author

I'll take a stab at it since I need to do it anyway to play with the range metadata.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants