[llvm-commits] [llvm] r138885 - /llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp

Owen Anderson resistor at mac.com
Wed Aug 31 13:00:11 PDT 2011


Author: resistor
Date: Wed Aug 31 15:00:11 2011
New Revision: 138885

URL: http://llvm.org/viewvc/llvm-project?rev=138885&view=rev
Log:
When performing instruction selection for LDR_PRE_IMM/LDRB_PRE_IMM, we still need to preserve the sign of the index.  This fixes miscompilations of Quicksort in the nightly testsuite, and hopefully others as well.
<rdar://problem/10046188>

Modified:
    llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp

Modified: llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp?rev=138885&r1=138884&r2=138885&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp (original)
+++ llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp Wed Aug 31 15:00:11 2011
@@ -759,8 +759,15 @@
 
 bool ARMDAGToDAGISel::SelectAddrMode2OffsetImmPre(SDNode *Op, SDValue N,
                                             SDValue &Offset, SDValue &Opc) {
+  unsigned Opcode = Op->getOpcode();
+  ISD::MemIndexedMode AM = (Opcode == ISD::LOAD)
+    ? cast<LoadSDNode>(Op)->getAddressingMode()
+    : cast<StoreSDNode>(Op)->getAddressingMode();
+  ARM_AM::AddrOpc AddSub = (AM == ISD::PRE_INC || AM == ISD::POST_INC)
+    ? ARM_AM::add : ARM_AM::sub;
   int Val;
   if (isScaledConstantInRange(N, /*Scale=*/1, 0, 0x1000, Val)) { // 12 bits.
+    if (AddSub == ARM_AM::sub) Val *= -1;
     Offset = CurDAG->getRegister(0, MVT::i32);
     Opc = CurDAG->getTargetConstant(Val, MVT::i32);
     return true;
@@ -2316,7 +2323,7 @@
   Ops.push_back(Node->getOperand(1)); // Ptr
   Ops.push_back(Node->getOperand(2)); // Low part of Val1
   Ops.push_back(Node->getOperand(3)); // High part of Val1
-  if (Opc == ARM::ATOMCMPXCHG6432) { 
+  if (Opc == ARM::ATOMCMPXCHG6432) {
     Ops.push_back(Node->getOperand(4)); // Low part of Val2
     Ops.push_back(Node->getOperand(5)); // High part of Val2
   }





More information about the llvm-commits mailing list