[llvm] r223205 - R600/SI: Fix suspicious indexing
Matt Arsenault
Matthew.Arsenault at amd.com
Tue Dec 2 21:22:32 PST 2014
Author: arsenm
Date: Tue Dec 2 23:22:32 2014
New Revision: 223205
URL: http://llvm.org/viewvc/llvm-project?rev=223205&view=rev
Log:
R600/SI: Fix suspicious indexing
The loop is over the operands of an instruction, and checks the
register with the sub reg index of the dest register. This probably
meant to be checking the sub reg index of the same operand.
Modified:
llvm/trunk/lib/Target/R600/SIFixSGPRCopies.cpp
Modified: llvm/trunk/lib/Target/R600/SIFixSGPRCopies.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/R600/SIFixSGPRCopies.cpp?rev=223205&r1=223204&r2=223205&view=diff
==============================================================================
--- llvm/trunk/lib/Target/R600/SIFixSGPRCopies.cpp (original)
+++ llvm/trunk/lib/Target/R600/SIFixSGPRCopies.cpp Tue Dec 2 23:22:32 2014
@@ -219,11 +219,13 @@ bool SIFixSGPRCopies::runOnMachineFuncti
case AMDGPU::PHI: {
DEBUG(dbgs() << "Fixing PHI: " << MI);
- for (unsigned i = 1; i < MI.getNumOperands(); i+=2) {
- unsigned Reg = MI.getOperand(i).getReg();
- const TargetRegisterClass *RC = inferRegClassFromDef(TRI, MRI, Reg,
- MI.getOperand(0).getSubReg());
- MRI.constrainRegClass(Reg, RC);
+ for (unsigned i = 1; i < MI.getNumOperands(); i += 2) {
+ const MachineOperand &Op = MI.getOperand(i);
+ unsigned Reg = Op.getReg();
+ const TargetRegisterClass *RC
+ = inferRegClassFromDef(TRI, MRI, Reg, Op.getSubReg());
+
+ MRI.constrainRegClass(Op.getReg(), RC);
}
unsigned Reg = MI.getOperand(0).getReg();
const TargetRegisterClass *RC = inferRegClassFromUses(TRI, MRI, Reg,
More information about the llvm-commits
mailing list