This is an NFC patch and it only concerns compiling time on targets where isNumRegsMajorCostOfLSR is overloaded. For now, it is only for PowerPC target.
Because all the collected chains will be marked as not profitable in isProfitableChain when isNumRegsMajorCostOfLSR returns false, we don't need to waste time to collect the chain at the very beginning.
This patch just reverts the change in function isProfitableChain in https://reviews.llvm.org/D89665 and moves the newly added hook check at the very beginning.
We may get a potential issue if another hook isProfitableLSRChainElement returns true for some chain element on targets that isNumRegsMajorCostOfLSR returns false, but for now I can not see any target do that. So I guess it should be ok now?