[NFC] ConstantMerge: factor out some functions

This makes the code easier to read and will make an upcoming patch I have easier to review because that patch needed this refactoring to reuse some of the functions.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339391 91177308-0d34-0410-b5e6-96231b3b80d8
1 file changed