[llvm-commits] [llvm] r97670 - /llvm/trunk/lib/CodeGen/MachineInstr.cpp
Evan Cheng
evan.cheng at apple.com
Wed Mar 3 13:54:14 PST 2010
Author: evancheng
Date: Wed Mar 3 15:54:14 2010
New Revision: 97670
URL: http://llvm.org/viewvc/llvm-project?rev=97670&view=rev
Log:
Fix funky indentation and add comments.
Modified:
llvm/trunk/lib/CodeGen/MachineInstr.cpp
Modified: llvm/trunk/lib/CodeGen/MachineInstr.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineInstr.cpp?rev=97670&r1=97669&r2=97670&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MachineInstr.cpp (original)
+++ llvm/trunk/lib/CodeGen/MachineInstr.cpp Wed Mar 3 15:54:14 2010
@@ -704,24 +704,31 @@
bool MachineInstr::isIdenticalTo(const MachineInstr *Other,
MICheckType Check) const {
- if (Other->getOpcode() != getOpcode() ||
- Other->getNumOperands() != getNumOperands())
+ // If opcodes or number of operands are not the same then the two
+ // instructions are obviously not identical.
+ if (Other->getOpcode() != getOpcode() ||
+ Other->getNumOperands() != getNumOperands())
+ return false;
+
+ // Check operands to make sure they match.
+ for (unsigned i = 0, e = getNumOperands(); i != e; ++i) {
+ const MachineOperand &MO = getOperand(i);
+ const MachineOperand &OMO = Other->getOperand(i);
+ // Clients may or may not want to ignore defs when testing for equality.
+ // For example, machine CSE pass only cares about finding common
+ // subexpressions, so it's safe to ignore virtual register defs.
+ if (Check != CheckDefs && MO.isReg() && MO.isDef()) {
+ if (Check == IgnoreDefs)
+ continue;
+ // Check == IgnoreVRegDefs
+ if (TargetRegisterInfo::isPhysicalRegister(MO.getReg()) ||
+ TargetRegisterInfo::isPhysicalRegister(OMO.getReg()))
+ if (MO.getReg() != OMO.getReg())
+ return false;
+ } else if (!MO.isIdenticalTo(OMO))
return false;
- for (unsigned i = 0, e = getNumOperands(); i != e; ++i) {
- const MachineOperand &MO = getOperand(i);
- const MachineOperand &OMO = Other->getOperand(i);
- if (Check != CheckDefs && MO.isReg() && MO.isDef()) {
- if (Check == IgnoreDefs)
- continue;
- // Check == IgnoreVRegDefs
- if (TargetRegisterInfo::isPhysicalRegister(MO.getReg()) ||
- TargetRegisterInfo::isPhysicalRegister(OMO.getReg()))
- if (MO.getReg() != OMO.getReg())
- return false;
- } else if (!MO.isIdenticalTo(OMO))
- return false;
- }
- return true;
+ }
+ return true;
}
/// removeFromParent - This method unlinks 'this' from the containing basic
More information about the llvm-commits
mailing list