[llvm] r230297 - Fix handling of negative offsets for AddrModeT2_i8s4 in rewriteT2FrameIndex.

Bob Wilson bob.wilson at apple.com
Mon Feb 23 17:37:32 PST 2015


Author: bwilson
Date: Mon Feb 23 19:37:31 2015
New Revision: 230297

URL: http://llvm.org/viewvc/llvm-project?rev=230297&view=rev
Log:
Fix handling of negative offsets for AddrModeT2_i8s4 in rewriteT2FrameIndex.

This is a follow up to r230233 to fix something that I noticed by
inspection. The AddrModeT2_i8s4 addressing mode does not support
negative offsets. I spent a good chunk of the day trying to come up with
a testcase for this but was not successful. This addressing mode is used
to spill and restore GPRPair registers in Thumb2 code and that does not
happen often. We also make very limited used of negative offsets when
lowering frame indexes. I am going ahead with the change anyway, because
I am pretty confident that it is correct. I also added a missing assertion
to check that the low bits of the scaled offset are zero.

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

Modified: llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.cpp?rev=230297&r1=230296&r2=230297&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.cpp (original)
+++ llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.cpp Mon Feb 23 19:37:31 2015
@@ -575,12 +575,9 @@ bool llvm::rewriteT2FrameIndex(MachineIn
     } else if (AddrMode == ARMII::AddrModeT2_i8s4) {
       Offset += MI.getOperand(FrameRegIdx + 1).getImm() * 4;
       NumBits = 10; // 8 bits scaled by 4
-      // MCInst operand has already scaled value.
+      // MCInst operand expects already scaled value.
       Scale = 1;
-      if (Offset < 0) {
-        isSub = true;
-        Offset = -Offset;
-      }
+      assert((Offset & 3) == 0 && "Can't encode this offset!");
     } else {
       llvm_unreachable("Unsupported addressing mode!");
     }





More information about the llvm-commits mailing list