Tail duplication may modify the loop to a "non-canonical" form that CTR Loop pass can not
recognize. We fixed one issue in D135846. And we found in some other case, the loop is
changed to irreducible form. It is hard to fix this case in CTR loop pass, instead we reorder the
CTR loop pass before tail duplication pass and just after finalize-isel pass to avoid any unexpected
change to the loop form.
This patch:
1: reverted the change in d135846
2: move the ctrloop pass before tail duplication
IIUC, PPCCTRLoops should be enabled iff HardwareLoops is enabled. We'd better put the switch-on logic into separate function, and query this function when adding PPCCTRLoops and HardwareLoopsPass(and maybe PPCCTRLoopsVerify together) to the pipeline.