Skip to content

Commit 40c245c

Browse files
committed
Merging r251622:
------------------------------------------------------------------------ r251622 | vkalintiris | 2015-10-29 10:17:16 +0000 (Thu, 29 Oct 2015) | 17 lines [mips] Check the register class before replacing materializations of zero with $zero in microMIPS. Summary: The microMIPS register class GPRMM16 does not contain the $zero register. However, MipsSEDAGToDAGISel::replaceUsesWithZeroReg() would replace uses of the $dst register: [d]addiu, $dst, $zero, 0 with the $zero register, without checking for membership in the register class of the target machine operand. Reviewers: dsanders Subscribers: llvm-commits, dsanders Differential Revision: http://reviews.llvm.org/D13984 ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_37@252158 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 9364ca1 commit 40c245c

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

lib/Target/Mips/MipsSEISelDAGToDAG.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,11 @@ bool MipsSEDAGToDAGISel::replaceUsesWithZeroReg(MachineRegisterInfo *MRI,
115115
if (MI->isPHI() || MI->isRegTiedToDefOperand(OpNo) || MI->isPseudo())
116116
continue;
117117

118+
// Also, we have to check that the register class of the operand
119+
// contains the zero register.
120+
if (!MRI->getRegClass(MO.getReg())->contains(ZeroReg))
121+
continue;
122+
118123
MO.setReg(ZeroReg);
119124
}
120125

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
; RUN: llc -march=mips -mcpu=mips32r2 -mattr=+micromips,+nooddspreg -O0 < %s | FileCheck %s
2+
3+
; CHECK: addiu $[[R0:[0-9]+]], $zero, 0
4+
; CHECK: subu16 $2, $[[R0]], ${{[0-9]+}}
5+
define i32 @foo() {
6+
%1 = sub i32 0, undef
7+
ret i32 %1
8+
}

0 commit comments

Comments
 (0)