[SLP]Improve and simplify extendSchedulingRegion.

We do not need to scan further if the upper end or lower end of the
basic block is reached already and the instruction is not found. It
means that the instruction is definitely in the lower part of basic
block or in the upper block relatively.
This should improve compile time for the very big basic blocks.

Differential Revision: https://reviews.llvm.org/D99266

GitOrigin-RevId: 568c8741170fcaa6f7fa968578e1b99e94886b46
2 files changed