This is a fix for the compilation time increase caused by D60897. It caps the exploration performed by the look-ahead heuristic.
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.
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.
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.
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.
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.
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.