@@ -67,23 +67,16 @@ VirtRegRewriter::~VirtRegRewriter() {}
67
67
// / Note that operands may be added, so the MO reference is no longer valid.
68
68
static void substitutePhysReg (MachineOperand &MO, unsigned Reg,
69
69
const TargetRegisterInfo &TRI) {
70
- if (unsigned SubIdx = MO.getSubReg ()) {
71
- // Insert the physical subreg and reset the subreg field.
72
- MO.setReg (TRI.getSubReg (Reg, SubIdx));
73
- MO.setSubReg (0 );
74
-
75
- // Any def, dead, and kill flags apply to the full virtual register, so they
76
- // also apply to the full physical register. Add imp-def/dead and imp-kill
77
- // as needed.
70
+ if (MO.getSubReg ()) {
71
+ MO.substPhysReg (Reg, TRI);
72
+
73
+ // Any kill flags apply to the full virtual register, so they also apply to
74
+ // the full physical register.
75
+ // We assume that partial defs have already been decorated with a super-reg
76
+ // <imp-def> operand by LiveIntervals.
78
77
MachineInstr &MI = *MO.getParent ();
79
- if (MO.isDef ())
80
- if (MO.isDead ())
81
- MI.addRegisterDead (Reg, &TRI, /* AddIfNotFound=*/ true );
82
- else
83
- MI.addRegisterDefined (Reg, &TRI);
84
- else if (!MO.isUndef () &&
85
- (MO.isKill () ||
86
- MI.isRegTiedToDefOperand (&MO-&MI.getOperand (0 ))))
78
+ if (MO.isUse () && !MO.isUndef () &&
79
+ (MO.isKill () || MI.isRegTiedToDefOperand (&MO-&MI.getOperand (0 ))))
87
80
MI.addRegisterKilled (Reg, &TRI, /* AddIfNotFound=*/ true );
88
81
} else {
89
82
MO.setReg (Reg);
0 commit comments