-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
Hoist data pointer loads from array allocations #43547
Conversation
Since my branches are part of a fork, I've created a PR comparing this one and the array length propagation PR immediately before it here: pchintalapudi#3 |
487457a
to
00a9b49
Compare
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.
Can you add some unit-test specifically for the new llvm-array-opt pass?
src/ccall.cpp
Outdated
static_rt); | ||
if (auto array_alloc = dyn_cast<CallInst>(retval.V)) { | ||
array_alloc->addAttribute(AttributeList::ReturnIndex, Attribute::NoAlias); | ||
array_alloc->setMetadata("allocation.array", MDNode::get(jl_LLVMContext, {})); |
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.
I would prefer this MD to have a julia
prefix.
src/llvm-alloc-helpers.cpp
Outdated
@@ -301,3 +301,41 @@ void jl_alloc::runEscapeAnalysis(llvm::Instruction *I, EscapeAnalysisRequiredArg | |||
} | |||
} | |||
} | |||
|
|||
//FIXME: This doesn't actually work on Windows, as Windows inserts a trampoline |
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.
Comment is outdated now? Should instead explain why metadata
is used
00a9b49
to
9ed005b
Compare
943adc5
to
26e793b
Compare
When arrays are indexed into, the data pointer is loaded at the indexing site. Typically GVN moves this data pointer load out of loops, but we can do this more eagerly for 2D/3D array allocations and 1D array allocations that do not escape, enabling more of the optimization pipeline to come into play (e.g. loop vectorization).
This PR depends on #43487 for the initial array identification routine as well as the ArrayOpt pass, and therefore #43057 for the escape analysis improvements.
Example:
#43487 :
Godbolt: https://godbolt.org/z/9sr36nsvq
Benchmark:
PR:
Godbolt: https://godbolt.org/z/8qr8rYv14
Benchmark: