This is a fix for the compilation time increase caused by D60897. It caps the exploration performed by the look-ahead heuristic.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
- Build Status
Buildable 34094 Build 34093: arc lint + arc unit
Event Timeline
Please try this patch @phosek . Please let us know if it fixes the compilation-time issue. Thanks!
The defaults should probably be a new cl::opt<int>, and would be good to document the defaults somehow?
Yes, I agree @lebedev.ri they should be options with some documentation describing what they do.
Let's first get a confirmation that this is the actual cause of the compilation-time increase.
I'm getting the following error with this change:
ld.lld: llvm-project/llvm/include/llvm/IR/User.h:170: llvm::Value *llvm::User::getOperand(unsigned int) const: Assertion `i < NumUserOperands && "getOperand() out of range!"' failed.
Oops sorry about that @phosek . I wonder how none of the lit tests failed. Please try this one.
I tried the updated version and the build successfully finished and the build times are back to normal. Thank you for looking into this so promptly. Is it possible to land this change?
Thank you @phosek for testing it, I am glad it fixed the issue.
Let me add reviewers. I will push the change as soon as it gets approved by someone.
Just a very minor thing.
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp | ||
---|---|---|
158 | Maybe it is better to call this variable Look*A*headOperandsBudget, similar to the other ones. |
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp | ||
---|---|---|
158 | Yes, good point. |
Do you think you'll be able to land this change today or shall I revert D60897? Our bots have been broken since Thursday and we don't have any test coverage for our toolchain as a consequence.
Tests?
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp | ||
---|---|---|
921 | Do you really need this limit? |
Not sure what kind of test would be suitable for this change. It simply restricts the look-ahead heuristic to not visit more than 2 operands and 2 uses, which is not something visible in the output IR.
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp | ||
---|---|---|
921 | Yes, because it could be a call /phi instruction with many operands. |
You still need the test that demonstrates the effect of this change. You need to show that the option really affects the vectorization somehow.
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp | ||
---|---|---|
921 | Does this really the cause of the problems? It would be good to see some additional investigation if this is really required. |
OK let me try to create a test that causes a change in the IR.
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp | ||
---|---|---|
921 | This can cause problems if you have a look-ahead depth > 2. Consider the case where you have chains of phis or calls. You can spend a lot of time visiting all their operands. |
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp | ||
---|---|---|
921 | I would suggest investigating if this is really required. Most probably, users lookup budget should be enough. If the second change is really required, I would suggest to prepare it as a separate patch. |
Since this review is ongoing, please revert the original patch to unblock people. There is no harm in reverting and landing with the fix once it is ready. =]
We're seeing several compilation timeouts as well. Temporarily reverted in r364846 since this review is ongoing.
Maybe it is better to call this variable Look*A*headOperandsBudget, similar to the other ones.