The code was incorrectly counting the number of identical instructions, and therefore tried to predicate an instruction which should not have been predicated. This could have various effects: a compiler crash, an assembler failure, a miscompile, or just generating an extra, unnecessary instruction.
Instead of depending on TargetInstrInfo::removeBranch, which only works on analyzable branches, just remove all branch instructions.
Fixes https://bugs.llvm.org/show_bug.cgi?id=43121 and https://bugs.llvm.org/show_bug.cgi?id=41121 .
The previous code also decremented BBI1->NonPredSize. Do we not need to do that anymore?
(I don't know this code, just driving by.)