diff options
author | Chen Zheng <czhengsz@cn.ibm.com> | 2022-12-01 22:58:03 -0500 |
---|---|---|
committer | Chen Zheng <czhengsz@cn.ibm.com> | 2022-12-02 00:31:00 -0500 |
commit | b61ff0ca76a50e6eb2b110084b690823b94ff77f (patch) | |
tree | ae26cc92dd1a52c34a5e1eb34eb065b199f8ab25 /llvm/lib/Target/PowerPC/PPCTargetMachine.cpp | |
parent | dff8227189b4b6008143a4dd28f50eaa269a55c8 (diff) | |
download | llvm-b61ff0ca76a50e6eb2b110084b690823b94ff77f.zip llvm-b61ff0ca76a50e6eb2b110084b690823b94ff77f.tar.gz llvm-b61ff0ca76a50e6eb2b110084b690823b94ff77f.tar.bz2 |
[PowerPC] move ctrloop pass before tail duplication
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.
Reviewed By: lkail
Differential Revision: https://reviews.llvm.org/D138265
Diffstat (limited to 'llvm/lib/Target/PowerPC/PPCTargetMachine.cpp')
-rw-r--r-- | llvm/lib/Target/PowerPC/PPCTargetMachine.cpp | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/llvm/lib/Target/PowerPC/PPCTargetMachine.cpp b/llvm/lib/Target/PowerPC/PPCTargetMachine.cpp index fe396cb..9b28310 100644 --- a/llvm/lib/Target/PowerPC/PPCTargetMachine.cpp +++ b/llvm/lib/Target/PowerPC/PPCTargetMachine.cpp @@ -500,6 +500,11 @@ bool PPCPassConfig::addInstSelector() { } void PPCPassConfig::addMachineSSAOptimization() { + // Run CTR loops pass before any cfg modification pass to prevent the + // canonical form of hardware loop from being destroied. + if (!DisableCTRLoops && getOptLevel() != CodeGenOpt::None) + addPass(createPPCCTRLoopsPass()); + // PPCBranchCoalescingPass need to be done before machine sinking // since it merges empty blocks. if (EnableBranchCoalescing && getOptLevel() != CodeGenOpt::None) @@ -540,16 +545,6 @@ void PPCPassConfig::addPreRegAlloc() { if (EnableExtraTOCRegDeps) addPass(createPPCTOCRegDepsPass()); - // Run CTR loops pass before MachinePipeliner pass. - // MachinePipeliner will pipeline all instructions before the terminator, but - // we don't want DecreaseCTRPseudo to be pipelined. - // Note we may lose some MachinePipeliner opportunities if we run CTR loops - // generation pass before MachinePipeliner and the loop is converted back to - // a normal loop. We can revisit this later for running PPCCTRLoops after - // MachinePipeliner and handling DecreaseCTRPseudo in MachinePipeliner pass. - if (getOptLevel() != CodeGenOpt::None) - addPass(createPPCCTRLoopsPass()); - if (getOptLevel() != CodeGenOpt::None) addPass(&MachinePipelinerID); } |