@@ -37,13 +37,11 @@ namespace {
3737// instructions.
3838struct Reference {
3939 Reference ()
40- : Def(false ), Use(false ), IndirectDef( false ), IndirectUse( false ) {}
40+ : Def(false ), Use(false ) {}
4141
4242 Reference &operator |=(const Reference &Other) {
4343 Def |= Other.Def ;
44- IndirectDef |= Other.IndirectDef ;
4544 Use |= Other.Use ;
46- IndirectUse |= Other.IndirectUse ;
4745 return *this ;
4846 }
4947
@@ -53,11 +51,6 @@ struct Reference {
5351 // via a sub- or super-register.
5452 bool Def;
5553 bool Use;
56-
57- // True if the register is defined or used indirectly, by a sub- or
58- // super-register.
59- bool IndirectDef;
60- bool IndirectUse;
6154};
6255
6356class SystemZElimCompare : public MachineFunctionPass {
@@ -132,22 +125,18 @@ static bool resultTests(MachineInstr *MI, unsigned Reg) {
132125 return false ;
133126}
134127
135- // Describe the references to Reg in MI, including sub- and super-registers .
128+ // Describe the references to Reg or any of its aliases in MI .
136129Reference SystemZElimCompare::getRegReferences (MachineInstr *MI , unsigned Reg) {
137130 Reference Ref;
138131 for (unsigned I = 0 , E = MI ->getNumOperands (); I != E; ++I) {
139132 const MachineOperand &MO = MI ->getOperand (I);
140133 if (MO .isReg ()) {
141134 if (unsigned MOReg = MO .getReg ()) {
142- if (MOReg == Reg || TRI ->regsOverlap (MOReg, Reg)) {
143- if (MO .isUse ()) {
135+ if (TRI ->regsOverlap (MOReg, Reg)) {
136+ if (MO .isUse ())
144137 Ref.Use = true ;
145- Ref.IndirectUse |= (MOReg != Reg);
146- }
147- if (MO .isDef ()) {
138+ else if (MO .isDef ())
148139 Ref.Def = true ;
149- Ref.IndirectDef |= (MOReg != Reg);
150- }
151140 }
152141 }
153142 }
@@ -469,12 +458,11 @@ bool SystemZElimCompare::processBlock(MachineBasicBlock &MBB) {
469458 continue ;
470459 }
471460
472- Reference CCRefs (getRegReferences (MI , SystemZ::CC ));
473- if (CCRefs.Def ) {
461+ if (MI ->definesRegister (SystemZ::CC )) {
474462 CCUsers.clear ();
475463 CompleteCCUsers = true ;
476464 }
477- if (CompleteCCUsers && CCRefs. Use )
465+ if (MI -> readsRegister (SystemZ:: CC ) && CompleteCCUsers )
478466 CCUsers.push_back (MI );
479467 }
480468 return Changed;
0 commit comments