-
-
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
Add !noalias
and !alias.scope
metadata
#48256
Conversation
The main idea here is that the TBAA domain is ill-equipped for reasoning about regions (and, in particular, suffers total precision less when merging disparate types in a `memcpy`). Instead, `!noalias` should be used for region-based memory information and `!tbaa` should be used exclusively for layout. We use (5) regions corresponding to the top level of the TBAA tree: - gcframe - stack - data - constant - type_metadata For now, this leaves the TBAA hierarchy in tact and only adds additional `!noalias` metadata. `!tbaa` annotations should be the same as before.
This is an interim solution that derives the correct `!noalias` region from the existing TBAA information. Later we will want to: - Revise the TBAA hierarchy to remove region information - Delete `jl_aliasinfo_t::fromTBAA()` - Update `jl_cgval_t` to store a `jl_aliasinfo_t`
I gave it a once over and it LGTM, probably deserves nanosoldier/pkgeval runs though. |
@nanosoldier |
@nanosoldier |
Your benchmark job has completed - possible performance regressions were detected. A full report can be found here. |
I can confirm that the example in #47138 get fixed by this PR. julia> f(a, b) = for i in eachindex(a, b)
a[i] = b[i]
end
f (generic function with 2 methods)
julia> code_llvm(f, Tuple{Vector{ComplexF64},Vector{ComplexF64}}) |
At least locally, I get 66ns on master, 33ns on this PR and 23ns on 1.8. So it seems we've gotten a bit better here, but there's still something left. That something being lowering that memmove doesn't use SIMD. |
IIRC (The build has been deleted), the |
It generates a memmove because it can't prove the two arrays passed to the function don't alias each other. |
But I thought LLVM's vectorlizer is able to add a memcheck block and try to use simd if valid? |
I'm not sure if llvm is taking the |
I just check the Clang result. It vectorlized well. (Well, the input for LV pass does have seperate load and store...) |
So memcpyopt is transforming our memcpys into a memmove. Also your clang example isn't the same as your julia one. |
Oh my fault, didn't notice that. So at least |
Your package evaluation job has completed - possible new issues were detected. |
@nanosoldier |
Your benchmark job has completed - no performance regressions were detected. A full report can be found here. |
The motivation here is that the TBAA domain is ill-equipped for reasoning about regions. In particular, it suffers total precision loss when merging disparate types in a
memcpy
causing #47138.As suggested by @vtjnash,
!noalias
should probably be used for region-based memory information and!tbaa
should be used exclusively for layout. This change adds!noalias
annotations without modifying the TBAA hierarchy.All of the "interesting" changes are in 7313b7f (which resolves #47138 on its own). b08c644 just rolls out the same trick over (nearly) all other loads/stores.
We'll want to follow up soon to prune the TBAA hierarchy, which I think will be a strict improvement.