[llvm] 27dc4c3 - [X86FixupSetCC] Use MachineInstr::readRegister/definesRegister to check for EFLAGS use/def instead of our own custom operand scan. NFCI

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 24 20:55:39 PST 2019


Author: Craig Topper
Date: 2019-12-24T20:34:33-08:00
New Revision: 27dc4c319b53fb68424e6d791f20792a0bf8002f

URL: https://github.com/llvm/llvm-project/commit/27dc4c319b53fb68424e6d791f20792a0bf8002f
DIFF: https://github.com/llvm/llvm-project/commit/27dc4c319b53fb68424e6d791f20792a0bf8002f.diff

LOG: [X86FixupSetCC] Use MachineInstr::readRegister/definesRegister to check for EFLAGS use/def instead of our own custom operand scan. NFCI

Added: 
    

Modified: 
    llvm/lib/Target/X86/X86FixupSetCC.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/X86/X86FixupSetCC.cpp b/llvm/lib/Target/X86/X86FixupSetCC.cpp
index 09fa0e45b01d..8ecdce4fd0d3 100644
--- a/llvm/lib/Target/X86/X86FixupSetCC.cpp
+++ b/llvm/lib/Target/X86/X86FixupSetCC.cpp
@@ -47,9 +47,6 @@ class X86FixupSetCCPass : public MachineFunctionPass {
   MachineInstr *findFlagsImpDef(MachineBasicBlock *MBB,
                                 MachineBasicBlock::reverse_iterator MI);
 
-  // Return true if MI imp-uses eflags.
-  bool impUsesFlags(MachineInstr *MI);
-
   // Return true if this is the opcode of a SetCC instruction with a register
   // output.
   bool isSetCCr(unsigned Opode);
@@ -77,21 +74,12 @@ X86FixupSetCCPass::findFlagsImpDef(MachineBasicBlock *MBB,
   // FIXME: Should this be instr_rend(), and MI be reverse_instr_iterator?
   auto MBBStart = MBB->rend();
   for (int i = 0; (i < SearchBound) && (MI != MBBStart); ++i, ++MI)
-    for (auto &Op : MI->implicit_operands())
-      if (Op.isReg() && (Op.getReg() == X86::EFLAGS) && Op.isDef())
-        return &*MI;
+    if (MI->definesRegister(X86::EFLAGS))
+      return &*MI;
 
   return nullptr;
 }
 
-bool X86FixupSetCCPass::impUsesFlags(MachineInstr *MI) {
-  for (auto &Op : MI->implicit_operands())
-    if (Op.isReg() && (Op.getReg() == X86::EFLAGS) && Op.isUse())
-      return true;
-
-  return false;
-}
-
 bool X86FixupSetCCPass::runOnMachineFunction(MachineFunction &MF) {
   bool Changed = false;
   MRI = &MF.getRegInfo();
@@ -126,7 +114,7 @@ bool X86FixupSetCCPass::runOnMachineFunction(MachineFunction &MF) {
       // it, itself, by definition, clobbers eflags. But it may happen that
       // FlagsDefMI also *uses* eflags, in which case the transformation is
       // invalid.
-      if (impUsesFlags(FlagsDefMI))
+      if (FlagsDefMI->readsRegister(X86::EFLAGS))
         continue;
 
       ++NumSubstZexts;


        


More information about the llvm-commits mailing list