improve life with large tuples a little #16460
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I put the cutoff mentioned in #15702 in there.
tuple
_apply
inlining was unlimited.Otherwise it's mostly trying to avoid llvm scalarizing load/store of large aggregates. Instead it uses the memcpy intrinsics so it is lowered to a function call when the size exceeds some thresold.
It's not very systematic, I'm just going through examples I see with catastrophic IR explosion while throwing random large tuples around.
Without this patch, just passing a large tuple through to the constructor of a type like
generates an amount IR linear wrt the size of the tuple.
I'm hoping this won't prevent optimizations on small sizes (we may want to add our own thresold for that if it happens). Anyway, I trust llvm more to break up a small memcpy than merge a lot of loads.