@@ -37,13 +37,11 @@ namespace {
37
37
// instructions.
38
38
struct Reference {
39
39
Reference ()
40
- : Def(false ), Use(false ), IndirectDef( false ), IndirectUse( false ) {}
40
+ : Def(false ), Use(false ) {}
41
41
42
42
Reference &operator |=(const Reference &Other) {
43
43
Def |= Other.Def ;
44
- IndirectDef |= Other.IndirectDef ;
45
44
Use |= Other.Use ;
46
- IndirectUse |= Other.IndirectUse ;
47
45
return *this ;
48
46
}
49
47
@@ -53,11 +51,6 @@ struct Reference {
53
51
// via a sub- or super-register.
54
52
bool Def;
55
53
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;
61
54
};
62
55
63
56
class SystemZElimCompare : public MachineFunctionPass {
@@ -132,22 +125,18 @@ static bool resultTests(MachineInstr *MI, unsigned Reg) {
132
125
return false ;
133
126
}
134
127
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 .
136
129
Reference SystemZElimCompare::getRegReferences (MachineInstr *MI, unsigned Reg) {
137
130
Reference Ref;
138
131
for (unsigned I = 0 , E = MI->getNumOperands (); I != E; ++I) {
139
132
const MachineOperand &MO = MI->getOperand (I);
140
133
if (MO.isReg ()) {
141
134
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 ())
144
137
Ref.Use = true ;
145
- Ref.IndirectUse |= (MOReg != Reg);
146
- }
147
- if (MO.isDef ()) {
138
+ else if (MO.isDef ())
148
139
Ref.Def = true ;
149
- Ref.IndirectDef |= (MOReg != Reg);
150
- }
151
140
}
152
141
}
153
142
}
@@ -469,12 +458,11 @@ bool SystemZElimCompare::processBlock(MachineBasicBlock &MBB) {
469
458
continue ;
470
459
}
471
460
472
- Reference CCRefs (getRegReferences (MI, SystemZ::CC));
473
- if (CCRefs.Def ) {
461
+ if (MI->definesRegister (SystemZ::CC)) {
474
462
CCUsers.clear ();
475
463
CompleteCCUsers = true ;
476
464
}
477
- if (CompleteCCUsers && CCRefs. Use )
465
+ if (MI-> readsRegister (SystemZ::CC) && CompleteCCUsers )
478
466
CCUsers.push_back (MI);
479
467
}
480
468
return Changed;
0 commit comments