[llvm-commits] [llvm] r66056 - /llvm/trunk/lib/Target/X86/X86InstrInfo.cpp

Dan Gohman gohman at apple.com
Wed Mar 4 11:23:38 PST 2009


Author: djg
Date: Wed Mar  4 13:23:38 2009
New Revision: 66056

URL: http://llvm.org/viewvc/llvm-project?rev=66056&view=rev
Log:
When using MachineInstr operand indices on SDNodes, the number
of MachineInstr def operands must be subtracted out. This bug
was uncovered by the recent x86 EFLAGS optimization. Before
that, the only instructions that ever needed unfolding were
things like CMP32rm, where NumDefs is zero.

Modified:
    llvm/trunk/lib/Target/X86/X86InstrInfo.cpp

Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.cpp?rev=66056&r1=66055&r2=66056&view=diff

==============================================================================
--- llvm/trunk/lib/Target/X86/X86InstrInfo.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86InstrInfo.cpp Wed Mar  4 13:23:38 2009
@@ -2382,6 +2382,7 @@
   const TargetOperandInfo &TOI = TID.OpInfo[Index];
   const TargetRegisterClass *RC = TOI.isLookupPtrRegClass()
     ? RI.getPointerRegClass() : RI.getRegClass(TOI.RegClass);
+  unsigned NumDefs = TID.NumDefs;
   std::vector<SDValue> AddrOps;
   std::vector<SDValue> BeforeOps;
   std::vector<SDValue> AfterOps;
@@ -2389,11 +2390,11 @@
   unsigned NumOps = N->getNumOperands();
   for (unsigned i = 0; i != NumOps-1; ++i) {
     SDValue Op = N->getOperand(i);
-    if (i >= Index && i < Index+4)
+    if (i >= Index-NumDefs && i < Index-NumDefs+4)
       AddrOps.push_back(Op);
-    else if (i < Index)
+    else if (i < Index-NumDefs)
       BeforeOps.push_back(Op);
-    else if (i > Index)
+    else if (i > Index-NumDefs)
       AfterOps.push_back(Op);
   }
   SDValue Chain = N->getOperand(NumOps-1);





More information about the llvm-commits mailing list