This is needed since the SchedModel defines a list of write latencies, which is to be used by mapping to the MI operand order. Therefore the CC must not end up last in the list in the cases where RegAlloc adds an extra implicit-def operand.
In order to build a new MI, the iteration method in optimizeCompareZero() had to be fixed so that the iterator does not get invalidated as the old MI is erased.
RegAlloc adds such operands for the SuperReg it seems, when SubRegIdx != 0. The other potentially relevant cases where setDesc is called and then the CC register is added would be in SystemZShortenInst::shortenOn001AddCC. Those instructions do however not seem to use subregs to begin with, so it seems they do not need to worry about regalloc operands.
At least the SPEC looks good with just the LT handling per this patch.
Shouldn't this be rend instead of instr_rend, since this is a reverse_iterator, not a reverse_instr_iterator?