// instructions.
struct Reference {
Reference()
- : Def(false), Use(false), IndirectDef(false), IndirectUse(false) {}
+ : Def(false), Use(false) {}
Reference &operator|=(const Reference &Other) {
Def |= Other.Def;
- IndirectDef |= Other.IndirectDef;
Use |= Other.Use;
- IndirectUse |= Other.IndirectUse;
return *this;
}
// via a sub- or super-register.
bool Def;
bool Use;
-
- // True if the register is defined or used indirectly, by a sub- or
- // super-register.
- bool IndirectDef;
- bool IndirectUse;
};
class SystemZElimCompare : public MachineFunctionPass {
return false;
}
-// Describe the references to Reg in MI, including sub- and super-registers.
+// Describe the references to Reg or any of its aliases in MI.
Reference SystemZElimCompare::getRegReferences(MachineInstr *MI, unsigned Reg) {
Reference Ref;
for (unsigned I = 0, E = MI->getNumOperands(); I != E; ++I) {
const MachineOperand &MO = MI->getOperand(I);
if (MO.isReg()) {
if (unsigned MOReg = MO.getReg()) {
- if (MOReg == Reg || TRI->regsOverlap(MOReg, Reg)) {
- if (MO.isUse()) {
+ if (TRI->regsOverlap(MOReg, Reg)) {
+ if (MO.isUse())
Ref.Use = true;
- Ref.IndirectUse |= (MOReg != Reg);
- }
- if (MO.isDef()) {
+ else if (MO.isDef())
Ref.Def = true;
- Ref.IndirectDef |= (MOReg != Reg);
- }
}
}
}
continue;
}
- Reference CCRefs(getRegReferences(MI, SystemZ::CC));
- if (CCRefs.Def) {
+ if (MI->definesRegister(SystemZ::CC)) {
CCUsers.clear();
CompleteCCUsers = true;
}
- if (CompleteCCUsers && CCRefs.Use)
+ if (MI->readsRegister(SystemZ::CC) && CompleteCCUsers)
CCUsers.push_back(MI);
}
return Changed;