diff --git a/llvm/include/llvm/CodeGen/TargetInstrInfo.h b/llvm/include/llvm/CodeGen/TargetInstrInfo.h --- a/llvm/include/llvm/CodeGen/TargetInstrInfo.h +++ b/llvm/include/llvm/CodeGen/TargetInstrInfo.h @@ -1366,8 +1366,13 @@ /// If the specified instruction defines any predicate /// or condition code register(s) used for predication, returns true as well /// as the definition predicate(s) by reference. + /// IncludeRemovable should be set to true at any point that removable + /// predicate instructions should be considered as being defined. + /// A removable predicate instruction is one that is guaranteed to be removed + /// after a call to PredicateInstruction. virtual bool DefinesPredicate(MachineInstr &MI, - std::vector &Pred) const { + std::vector &Pred, + bool IncludeRemovable = false) const { return false; } diff --git a/llvm/lib/Target/AMDGPU/R600InstrInfo.h b/llvm/lib/Target/AMDGPU/R600InstrInfo.h --- a/llvm/lib/Target/AMDGPU/R600InstrInfo.h +++ b/llvm/lib/Target/AMDGPU/R600InstrInfo.h @@ -195,7 +195,8 @@ BranchProbability Probability) const override; bool DefinesPredicate(MachineInstr &MI, - std::vector &Pred) const override; + std::vector &Pred, + bool IncludeRemovable = false) const override; bool isProfitableToUnpredicate(MachineBasicBlock &TMBB, MachineBasicBlock &FMBB) const override; diff --git a/llvm/lib/Target/AMDGPU/R600InstrInfo.cpp b/llvm/lib/Target/AMDGPU/R600InstrInfo.cpp --- a/llvm/lib/Target/AMDGPU/R600InstrInfo.cpp +++ b/llvm/lib/Target/AMDGPU/R600InstrInfo.cpp @@ -964,7 +964,8 @@ } bool R600InstrInfo::DefinesPredicate(MachineInstr &MI, - std::vector &Pred) const { + std::vector &Pred, + bool IncludeRemovable) const { return isPredicateSetter(MI.getOpcode()); } diff --git a/llvm/lib/Target/ARM/ARMBaseInstrInfo.h b/llvm/lib/Target/ARM/ARMBaseInstrInfo.h --- a/llvm/lib/Target/ARM/ARMBaseInstrInfo.h +++ b/llvm/lib/Target/ARM/ARMBaseInstrInfo.h @@ -172,7 +172,8 @@ ArrayRef Pred2) const override; bool DefinesPredicate(MachineInstr &MI, - std::vector &Pred) const override; + std::vector &Pred, + bool IncludeRemovable = false) const override; bool isPredicable(const MachineInstr &MI) const override; diff --git a/llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp b/llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp --- a/llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp +++ b/llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp @@ -590,7 +590,7 @@ } bool ARMBaseInstrInfo::DefinesPredicate( - MachineInstr &MI, std::vector &Pred) const { + MachineInstr &MI, std::vector &Pred, bool IncludeRemovable) const { bool Found = false; for (unsigned i = 0, e = MI.getNumOperands(); i != e; ++i) { const MachineOperand &MO = MI.getOperand(i); diff --git a/llvm/lib/Target/Hexagon/HexagonInstrInfo.h b/llvm/lib/Target/Hexagon/HexagonInstrInfo.h --- a/llvm/lib/Target/Hexagon/HexagonInstrInfo.h +++ b/llvm/lib/Target/Hexagon/HexagonInstrInfo.h @@ -239,7 +239,8 @@ /// or condition code register(s) used for predication, returns true as well /// as the definition predicate(s) by reference. bool DefinesPredicate(MachineInstr &MI, - std::vector &Pred) const override; + std::vector &Pred, + bool IncludeRemovable = false) const override; /// Return true if the specified instruction can be predicated. /// By default, this returns true for every instruction with a diff --git a/llvm/lib/Target/Hexagon/HexagonInstrInfo.cpp b/llvm/lib/Target/Hexagon/HexagonInstrInfo.cpp --- a/llvm/lib/Target/Hexagon/HexagonInstrInfo.cpp +++ b/llvm/lib/Target/Hexagon/HexagonInstrInfo.cpp @@ -1640,7 +1640,7 @@ } bool HexagonInstrInfo::DefinesPredicate(MachineInstr &MI, - std::vector &Pred) const { + std::vector &Pred, bool IncludeRemovable) const { const HexagonRegisterInfo &HRI = *Subtarget.getRegisterInfo(); for (unsigned oper = 0; oper < MI.getNumOperands(); ++oper) { diff --git a/llvm/lib/Target/PowerPC/PPCInstrInfo.h b/llvm/lib/Target/PowerPC/PPCInstrInfo.h --- a/llvm/lib/Target/PowerPC/PPCInstrInfo.h +++ b/llvm/lib/Target/PowerPC/PPCInstrInfo.h @@ -474,7 +474,8 @@ ArrayRef Pred2) const override; bool DefinesPredicate(MachineInstr &MI, - std::vector &Pred) const override; + std::vector &Pred, + bool IncludeRemovable = false) const override; // Comparison optimization. diff --git a/llvm/lib/Target/PowerPC/PPCInstrInfo.cpp b/llvm/lib/Target/PowerPC/PPCInstrInfo.cpp --- a/llvm/lib/Target/PowerPC/PPCInstrInfo.cpp +++ b/llvm/lib/Target/PowerPC/PPCInstrInfo.cpp @@ -1786,7 +1786,8 @@ } bool PPCInstrInfo::DefinesPredicate(MachineInstr &MI, - std::vector &Pred) const { + std::vector &Pred, + bool IncludeRemovable) const { // Note: At the present time, the contents of Pred from this function is // unused by IfConversion. This implementation follows ARM by pushing the // CR-defining operand. Because the 'DZ' and 'DNZ' count as types of