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 {
// 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;
}
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();
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.
# RUN: llc -mtriple powerpc64le-unknown-linux-gnu -mcpu=pwr8 -x mir < %s \
-# RUN: -verify-machineinstrs -start-before=ppc-mi-peepholes | FileCheck %s
+# RUN: -verify-machineinstrs -start-before=ppc-mi-peepholes \
+# RUN: -ppc-opt-conditional-trap | FileCheck %s
---
name: conditional_trap_opt_reg_implicit_def