[PATCH] [FastISel][X86] Assign the correct register class to folded operations
Juergen Ributzka
juergen at apple.com
Fri Nov 14 10:41:21 PST 2014
I think this should be done inside 'foldMemoryOperandImpl'. We shouldn't have to cleanup afterwards.
'constrainRegClass' may actually fail, so you need to check the result of this method if you use it .
================
Comment at: lib/Target/X86/X86FastISel.cpp:3348
@@ +3347,3 @@
+ MCInstrDesc MCID = Result->getDesc();
+ for (size_t i = 0; i < AddrOps.size(); ++i) {
+ MachineOperand &MO = AddrOps[i];
----------------
I don't think this is correct. The index "i" must line up with the MO index in the instruction and not with AddrOps.
================
Comment at: lib/Target/X86/X86FastISel.cpp:3350
@@ +3349,3 @@
+ MachineOperand &MO = AddrOps[i];
+ if (MO.getType() != MachineOperand::MO_Register)
+ continue;
----------------
MO.isReg() is shorter :)
================
Comment at: lib/Target/X86/X86FastISel.cpp:3353
@@ +3352,3 @@
+ unsigned Reg = MO.getReg();
+ if (!Reg || TargetRegisterInfo::isPhysicalRegister(Reg))
+ continue;
----------------
If you use TargetRegisterInfo::isVirtualRegister instead, you can even skip the MO.isReg() check.
================
Comment at: lib/Target/X86/X86FastISel.cpp:3355
@@ +3354,3 @@
+ continue;
+ MRI.constrainRegClass(Reg, TII.getRegClass(MCID, i, &TRI, *FuncInfo.MF));
+ }
----------------
This is not guaranteed to succeed - you need to check the result.
See FastISel::constrainOperandRegClass for more details.
http://reviews.llvm.org/D6262
More information about the llvm-commits
mailing list