This patch exploits the knowledge that we may be running many fewer than bitwidth iterations of the loop, and may be able to disallow the overflow case. This patch specifically implements only the shl case, but this can be generalized to ashr and lshr without difficulty.
In my motivating example (a multiple dimension loop nest w/a shl recurrence at the outer level), this results in a massive improvement in scev-aa results.
LI.isLoopHeader(P->getParent())?
I also wonder why is that needed. The implementation of matchSimpleRecurrence cannot recognize something which is not a header phi, because there is no other way to have BO as operand of Phi and vice versa at the same time. I guess this may be turned into assert after matchSimpleRecurrence.