diff options
| author | Victor Huang <wei.huang@ibm.com> | 2021-11-19 10:10:19 -0600 |
|---|---|---|
| committer | Victor Huang <wei.huang@ibm.com> | 2021-11-19 10:24:54 -0600 |
| commit | 86e77cdb081ff40b8b46099c935f8d343e26425e (patch) | |
| tree | 319b9a8ceb4bac1917440542ad0442da0b176a31 /llvm/lib/Target/PowerPC/PPCMIPeephole.cpp | |
| parent | ffe1741b5ccab07cbf45fe99033e4119688eb5a5 (diff) | |
[PowerPC] Add a flag for conditional trap optimization
This patch adds a flag to enable/disable conditional trap optimization.
Optimization disabled by default.
Peer reviewed by: nemanjai
Diffstat (limited to 'llvm/lib/Target/PowerPC/PPCMIPeephole.cpp')
| -rw-r--r-- | llvm/lib/Target/PowerPC/PPCMIPeephole.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/llvm/lib/Target/PowerPC/PPCMIPeephole.cpp b/llvm/lib/Target/PowerPC/PPCMIPeephole.cpp index 797e322de7e8..d12a9b806fd0 100644 --- a/llvm/lib/Target/PowerPC/PPCMIPeephole.cpp +++ b/llvm/lib/Target/PowerPC/PPCMIPeephole.cpp @@ -79,6 +79,11 @@ static cl::opt<bool> cl::desc("enable elimination of zero-extensions"), cl::init(false), cl::Hidden); +static cl::opt<bool> + EnableTrapOptimization("ppc-opt-conditional-trap", + cl::desc("enable optimization of conditional traps"), + cl::init(false), cl::Hidden); + namespace { struct PPCMIPeephole : public MachineFunctionPass { @@ -423,7 +428,7 @@ bool PPCMIPeephole::simplifyCode(void) { // If a conditional trap instruction got optimized to an // unconditional trap, eliminate all the instructions after // the trap. - if (TrapOpt) { + if (EnableTrapOptimization && TrapOpt) { ToErase = &MI; continue; } @@ -1020,6 +1025,7 @@ bool PPCMIPeephole::simplifyCode(void) { case PPC::TWI: case PPC::TD: case PPC::TW: { + if (!EnableTrapOptimization) break; MachineInstr *LiMI1 = getVRegDefOrNull(&MI.getOperand(1), MRI); MachineInstr *LiMI2 = getVRegDefOrNull(&MI.getOperand(2), MRI); bool IsOperand2Immediate = MI.getOperand(2).isImm(); @@ -1068,7 +1074,8 @@ bool PPCMIPeephole::simplifyCode(void) { ToErase = nullptr; } // Reset TrapOpt to false at the end of the basic block. - TrapOpt = false; + if (EnableTrapOptimization) + TrapOpt = false; } // Eliminate all the TOC save instructions which are redundant. |
