33 #define DEBUG_TYPE "x86-fixup-setcc" 35 STATISTIC(NumSubstZexts,
"Number of setcc + zext pairs substituted");
42 StringRef getPassName()
const override {
return "X86 Fixup SetCC"; }
56 bool isSetCCr(
unsigned Opode);
61 enum { SearchBound = 16 };
71 bool X86FixupSetCCPass::isSetCCr(
unsigned Opcode) {
103 auto MBBStart = MBB->
rend();
104 for (
int i = 0; (i < SearchBound) && (MI != MBBStart); ++i, ++
MI)
105 for (
auto &
Op : MI->implicit_operands())
106 if ((
Op.getReg() == X86::EFLAGS) && (
Op.isDef()))
112 bool X86FixupSetCCPass::impUsesFlags(
MachineInstr *MI) {
114 if ((
Op.getReg() == X86::EFLAGS) && (
Op.isUse()))
121 bool Changed =
false;
127 for (
auto &MBB : MF) {
128 for (
auto &MI : MBB) {
137 if (
Use.getOpcode() == X86::MOVZX32rr8)
154 if (impUsesFlags(FlagsDefMI))
163 : &X86::GR32_ABCDRegClass;
164 unsigned ZeroReg =
MRI->createVirtualRegister(RC);
165 unsigned InsertReg =
MRI->createVirtualRegister(RC);
174 TII->get(X86::INSERT_SUBREG), InsertReg)
177 .addImm(X86::sub_8bit);
183 for (
auto &
I : ToErase)
184 I->eraseFromParent();
This class represents lattice values for constants.
void push_back(const T &Elt)
const DebugLoc & getDebugLoc() const
Returns the debug location id of this MachineInstr.
FunctionPass * createX86FixupSetCC()
Return a pass that transforms setcc + movzx pairs into xor + setcc.
unsigned getReg() const
getReg - Returns the register number.
STATISTIC(NumFunctions, "Total number of functions")
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
const HexagonInstrInfo * TII
A Use represents the edge between a Value definition and its users.
MachineBasicBlock iterator that automatically skips over MIs that are inside bundles (i...
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
MachineInstrBundleIterator< MachineInstr, true > reverse_iterator
MachineInstrBuilder BuildMI(MachineFunction &MF, const DebugLoc &DL, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
unsigned const MachineRegisterInfo * MRI
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
static bool is64Bit(const char *name)
FunctionPass class - This class is used to implement most global optimizations.
iterator_range< mop_iterator > implicit_operands()
const MachineBasicBlock * getParent() const
MachineRegisterInfo - Keep track of information for virtual and physical registers, including vreg register classes, use/def chains for registers, etc.
Representation of each machine instruction.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
const MachineInstrBuilder & addReg(unsigned RegNo, unsigned flags=0, unsigned SubReg=0) const
Add a new virtual register operand.
StringRef - Represent a constant reference to a string, i.e.
const MachineOperand & getOperand(unsigned i) const