RenameIndependentSubregs: Fix infinite loop

Apparently this replacement can really be substituting the
same as the original register. Avoid restarting the loop
when there's been no change in the register uses.

llvm-svn: 306441
This commit is contained in:
Matt Arsenault 2017-06-27 18:28:10 +00:00
parent 7c44f340de
commit 836d786e86
2 changed files with 21 additions and 1 deletions

View File

@ -243,7 +243,8 @@ void RenameIndependentSubregs::rewriteOperands(const IntEqClasses &Classes,
unsigned VReg = Intervals[ID]->reg;
MO.setReg(VReg);
if (MO.isTied()) {
if (MO.isTied() && Reg != VReg) {
/// Undef use operands are not tracked in the equivalence class but need
/// to be update if they are tied.
MO.getParent()->substituteRegister(Reg, VReg, 0, TRI);

View File

@ -134,3 +134,22 @@ body: |
S_SETPC_B64_return %sgpr30_sgpr31, implicit %sgpr5
...
# GCN-LABEL: name: inf_loop_tied_operand
# GCN: bb.0:
# GCN-NEXT: undef %2.sub0 = V_MAC_F32_e32 1073741824, undef %0, undef %2.sub0, implicit %exec
# GCN-NEXT: dead undef %3.sub1 = COPY %2.sub0
name: inf_loop_tied_operand
tracksRegLiveness: true
registers:
- { id: 0, class: vgpr_32, preferred-register: '' }
- { id: 1, class: vgpr_32, preferred-register: '' }
- { id: 2, class: vreg_128, preferred-register: '' }
body: |
bb.0:
%1 = V_MAC_F32_e32 1073741824, undef %0, undef %1, implicit %exec
undef %2.sub0 = COPY %1
%2.sub1 = COPY %1
...